Repository navigation
Fix aggregation of unrecognized raw metadata fields - #1452
Open
Ganesh1729-ui wants to merge 1 commit into
Open
Ganesh1729-ui wants to merge 1 commit into
Ganesh1729-ui wants to merge 1 commit into
Conversation
Wkhanex
reviewed
Oct 16, 2026
Wkhanex
left a comment
There was a problem hiding this comment.
AI-assisted validation at 3778cdf9bc26 on Python 3.12.14: I exercised missing, invalid (0.0), and valid (2.6) metadata versions with five unrecognized names: unknown_field, from_raw, from_email, _raw, and __dict__. All 15 cases produced grouped InvalidMetadata errors containing exactly the offending field plus the metadata-version error when applicable. The caller's input mapping remained unchanged. All 353 metadata tests passed.
Including _raw and __dict__ is a useful extension to the classmethod collisions in the added tests: these names also exist on the class but are not metadata validators. The descriptor lookup now rejects those without escaping the aggregation path.
This branch has not been deployed
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
Metadata.from_raw(..., validate=True)can escape its grouped validation errors when an unrecognized field is combined with a missing or invalidmetadata_version. A misspelled field raisesAttributeError; keys such asfrom_rawandfrom_emailcan also raiseAttributeErroror disappear from the collected errors.Check whether each raw key names a validator before the conditional metadata-version age check. Collect keys without a validator as
InvalidMetadata, including classmethod-name collisions. This lets the existing collector report both the metadata-version error and the unrecognized field.Reproduction
Before:
AttributeErrorfordynamcescapes validation.After: the documented
ExceptionGroupcontainsInvalidMetadatafor bothmetadata-versionanddynamc.The nine parametrized regressions cover a misspelled key and both classmethod-name collisions, each with a missing, invalid or valid metadata version. Eight fail on unchanged main; the valid-version misspelled-key case is an existing-behavior control.
Validation
nox -s lint: all hooks, source/wheel build and Twine checks pass.Fork validation verifies the eight expected failures on unchanged main, then runs the complete patched Linux sessions and lint checks. Its helper workflow is on a separate fork-only branch; this PR changes only the validator and its tests.