Repository navigation
feat: Replace from_avro_datum* functions with GenericDatumReader - #496
Merged
Merged
Conversation
Kriskras99
force-pushed
the
feat/generic_datum_reader
branch
from
March 3, 2026 14:01
25fe8a2 to
83ffedb
Compare
Kriskras99
force-pushed
the
feat/generic_datum_reader
branch
from
March 5, 2026 07:22
83ffedb to
07a261f
Compare
Contributor
Author
|
Merge conflicts resolved |
martin-g
reviewed
Mar 5, 2026
martin-g
approved these changes
Mar 5, 2026
This was referenced Jun 1, 2026
martin-g
pushed a commit
that referenced
this pull request
Jun 8, 2026
…pe-ref (#547) (#548) * fix(schema): return Err instead of panicking on invalid name/alias/type-ref `Schema::parse_str` panicked on schema JSON whose alias, type reference, or nested type name is not a valid Avro identifier, because three sites in `schema::parser` called `Name::new(..).unwrap()` / `Alias::new(..).unwrap()` on values that already return `AvroResult`. Since `parse_str` is a public `Result`-returning API, callers cannot guard against the unwind, so parsing untrusted schema JSON was a DoS. This is the sibling of the `Name::parse` fix in #496. - `get_already_seen_schema`: an unparseable type name cannot match an already-seen schema, so return `None` (`.ok()?`) rather than unwrap. - `fix_aliases_namespace`: return `AvroResult<Aliases>` and propagate; an invalid alias is a schema error (`?` added at the three call sites). - `get_schema_type_name`: fall back to the enclosing name (`unwrap_or(name)`), matching the existing `_ => name` arm. Adds a regression test (tests/avro-rs-547.rs) covering invalid aliases, nested names and type references, plus a positive case ensuring valid aliases still parse. Fixes #547 Signed-off-by: youichi-uda <[email protected]> * address review: avoid clones in fix_aliases_namespace; propagate in get_schema_type_name - fix_aliases_namespace: use `contains('.')` and pass `&str` / `&format!(..)` directly to `Alias::new`, dropping the intermediate `qualified` String and the per-alias clones. - get_schema_type_name: return `AvroResult<Name>` and propagate the validation error (callers updated with `?`) instead of silently falling back to the enclosing name on an invalid nested `type` name. Signed-off-by: youichi-uda <[email protected]> --------- Signed-off-by: youichi-uda <[email protected]> Co-authored-by: youichi-uda <[email protected]>
Closed
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.
The
from_avro_datum*functions have been deprecated and point toGenericDatumReader.I've also made the
readermodule public so that users need to importGenericDatumReaderfromreader::datum. This should further discourage users from using this.I also want to this for the
to_avro_datum*functions, but I'll first make a PR makingwriter.rsa directory module.