fix(schema): enforce and document metadata.tags cardinality limit - #25
Open
dacostafrankaboagye wants to merge 1 commit into
Open
Conversation
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
Closes #17.
The schema spec's field reference states
metadata.tagshas a "Maximum50 entries" constraint, but the formal Validation rules section (items
1–6) never listed it, and — more importantly — the constraint wasn't
actually enforced in code at all.
PerformanceSnapshot.from_dict()would silently accept a
tagsdict of any size or key/value type.Changes
flameiq/schema/v1/models.py— addedSnapshotMetadata.__post_init__,following the same pattern as
LatencyMetrics/Metricselsewhere inthis module. Raises
ValueErroriftagshas more than 50 entries,or if any key/value is not a
str.docs/source/specs/schema-v1.rst— added validation rule 7,matching the field reference, and clarified that violating it raises
ValueError(notSchemaVersionError— that class is reserved forunsupported
schema_versionvalues and isn't used elsewhere in thismodule; every other check here raises plain
ValueError).tests/unit/test_schema/test_models.py— addedTestSnapshotMetadatacovering: exactly 50 tags (valid boundary), 51 tags (raises), non-string
key (raises), non-string value (raises).
Acceptance criteria (from #17)
test if missing — it did not enforce it at all; now it does
SchemaVersionErroror a different exception — clarified as
ValueError, forconsistency with the rest of the module
Testing
pytest tests/unit/test_schema/test_models.py -v— all 19 tests pass(4 new)
flameiq validatewith a metrics filecontaining 55 tags (fails with the new error message) and 45 tags
(passes)