[fix][broker] Use compatible Avro name validator to allow '$' in schema record names#25193
Open
mattisonchao wants to merge 7 commits intomasterfrom
Open
[fix][broker] Use compatible Avro name validator to allow '$' in schema record names#25193mattisonchao wants to merge 7 commits intomasterfrom
mattisonchao wants to merge 7 commits intomasterfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses a regression introduced by the Avro upgrade (1.12.0) where Protobuf-derived Avro schemas can fail parsing due to $ appearing in generated record names, by introducing a more permissive Avro NameValidator and adding tests to cover the scenario.
Changes:
- Add a custom Avro
NameValidator(CompatibleNameValidator) to allow$in Avro record/field names during schema validation. - Add unit tests for the validator’s behavior and a reproduction test using a generated Protobuf schema.
- Introduce a new Protobuf message (
DataRecord.proto) used by the tests.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| pulsar-broker/src/main/java/org/apache/pulsar/broker/service/schema/validator/StructSchemaDataValidator.java | Uses a custom Avro NameValidator to accept $ during schema parsing/validation. |
| pulsar-broker/src/test/java/org/apache/pulsar/broker/service/schema/validator/SchemaDataValidatorTest.java | Adds tests for the new validator and a Protobuf-based reproduction. |
| pulsar-broker/src/main/proto/DataRecord.proto | Adds a Protobuf schema used to generate Avro with nested-type $ names for testing. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
...c/main/java/org/apache/pulsar/broker/service/schema/validator/StructSchemaDataValidator.java
Show resolved
Hide resolved
...c/main/java/org/apache/pulsar/broker/service/schema/validator/StructSchemaDataValidator.java
Show resolved
Hide resolved
...src/test/java/org/apache/pulsar/broker/service/schema/validator/SchemaDataValidatorTest.java
Show resolved
Hide resolved
...src/test/java/org/apache/pulsar/broker/service/schema/validator/SchemaDataValidatorTest.java
Outdated
Show resolved
Hide resolved
lhotari
reviewed
Jan 29, 2026
...c/main/java/org/apache/pulsar/broker/service/schema/validator/StructSchemaDataValidator.java
Show resolved
Hide resolved
…PATIBLE_NAME_VALIDATOR
lhotari
reviewed
Feb 24, 2026
Member
There was a problem hiding this comment.
is this file for tests? I think it should be in pulsar-broker/src/test/proto directory in that case.
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.
Motivation
After #24617 upgraded Avro to a newer version, the default
Schema.Parser()uses
UTF_VALIDATORwhich rejects the$character in record names. Thisbreaks Protobuf schemas whose Avro representation contains
$in generatednested type names (e.g. inner classes).
Modifications
CompatibleNameValidatorthat allows$in addition to letters,digits, and underscores, matching the previous Avro behavior.
Schema.Parser()instancesthat handle Protobuf schemas:
StructSchemaDataValidatorSchemaRegistryServiceImplAvroSchemaBasedCompatibilityCheckDataRecord.protofor test reproduction.CompatibleNameValidatorand Protobuf schemacompatibility.
Verifying this change
CompatibleNameValidator(valid names, invalid names,edge cases, error messages).
ProtobufSchema<DataRecord>to reproduce the original issue.Documentation
doc-not-needed