Repository navigation
feat(kafka)!: encode a record against its registered schema without registering - #44
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…egistering Encoding reads the schema the subject already holds, its latest version or a named one, and writes the record with it. It no longer derives a schema from the values and registers it, so encoding changes nothing in the registry. A record that does not fit is refused as INVALID_ARGUMENT naming the field; an unknown subject or version is NOT_FOUND. Protobuf writes the named message (the first by default) with its message-index framing, JSON Schema records are validated, and a Protobuf schema that declares a package can now be read. BREAKING CHANGE: SchemaCatalog.encode(serde, subject, record) is removed. Call encode(serde, subject, EncodeOptions.latest(), record), which returns Encoded (use bytes() for the payload). If the subject has no schema yet, register one first with register(...); encode no longer creates it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Registered schemas are JSON, and the YAML reader brought a snakeyaml-engine that diverged from the one the Artemis driver brings, which failed the dependency-convergence rule. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…code accepts A refusal no longer carries a map key or a value: map entries are shown as [], and a JSON Schema refusal is built from the failed rule and the field path instead of the validator's message. A Protobuf schema is read with the schema library's parser, so a package, qualified type names and comments mentioning a package all resolve. An Avro default fills only an absent field, an explicit null stays null, and a union branch of the value's own type wins. Protobuf unsigned and fixed-width integers take their full range, a record setting two fields of one oneof is refused naming both, whole BigInteger values are accepted where they fit, and an Avro decimal accepts a BigDecimal that fits its scale and precision. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…as a field name A field the schema declares is named. One it does not declare is named only when it looks like an identifier, which keeps a typo useful; any other key, such as a card number or an address, shows as [] in Avro, Protobuf and JSON Schema refusals. An Avro union branch for a string now accepts any character sequence. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
SchemaCatalog.encodeused to derive a schema from the record's values and register it before framing, so producing a record had a side effect on the registry. This change makes encode a read-only operation against a schema that is already registered.encode(String serdeName, String subject, EncodeOptions options, Map<String, ?> record)returnsEncoded(bytes, schema id, subject, version, type, message name, whether the record was validated).EncodeOptions: the subject's latest version or a named one, and for Protobuf the message to write (the first by default), with the message-index framing.com.networknt:json-schema-validator(its YAML reader excluded).INVALID_ARGUMENTnaming the field, not sent; an unknown subject or version isNOT_FOUND. Encode issues only reads to the registry.packagedeclaration could not be read.broker-sdk-kafkaspec updated; OpenSpec change archived.BREAKING CHANGE: the three-argument
encode(serde, subject, record)is removed. Register the schema first withregister(...)where the subject has none, then callencode(serde, subject, EncodeOptions.latest(), record).Test plan
RegisteredEncodeTest(9),SchemaSerdeTest(5),SchemaRegistryNoteTest(3) locallySchemaRoundTripIT(register, encode, decode back, version list unchanged), japicmp (break expected under 0.x)🤖 Generated with Claude Code