Skip to content

fix!: Stricter schema parsing - #479

Merged
martin-g merged 3 commits into
mainfrom
fix/stricter_schema_parsing
Feb 24, 2026
Merged

martin-g merged 3 commits into
mainfrom
fix/stricter_schema_parsing

Conversation

@Kriskras99

Copy link
Copy Markdown
Contributor

This will break code, as it no longer accepts invalid schemas.

Closes #476

@martin-g martin-g left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here are some comments on the proposed changes in this PR.

But as I commented at #476 (comment) the Java and Python SDKs do support parsing such flat schemas too.

Comment thread avro/src/schema/mod.rs Resolved
Comment thread avro/src/schema/mod.rs Outdated
let result = Schema::parse_str(schema_str).unwrap_err();
assert_eq!(
result.to_string(),
"Invalid schema: There is no type called 'enum', if you meant to define a non-primitive schema, it should be defined inside `type` attribute. Please review the specification"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"Invalid schema: There is no type called 'enum', if you meant to define a non-primitive schema, it should be defined inside `type` attribute. Please review the specification"
"Invalid schema: There is no type called 'enum', if you meant to define a non-primitive schema, it should be defined inside `type` attribute. Please consult with the specification"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've removed the entire Please review the specification/Please consult with the specification bit

Comment thread avro/src/error.rs Resolved
Comment thread avro/src/schema/record/field.rs Resolved
Comment thread avro/src/schema/record/field.rs Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs reworking too.
logicalType, symbols, size, items and values cannot be at that level anymore.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've also removed the position field, as it is not in the spec or used in the code.

Comment thread avro/src/schema/record/field.rs Resolved
@Kriskras99
Kriskras99 requested a review from martin-g February 23, 2026 19:38
@martin-g martin-g added this to the 0.22.0 milestone Feb 24, 2026
@martin-g
martin-g merged commit 5dc46c0 into main Feb 24, 2026
21 checks passed
@Kriskras99
Kriskras99 deleted the fix/stricter_schema_parsing branch March 26, 2026 19:09
@Kriskras99 Kriskras99 mentioned this pull request Jun 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

type.enum is valid while it should fail, good is type.type.enum according to spec

2 participants