Repository navigation
feat!: add OscalBuilderError and a key for make_resource - #78
Merged
Merged
Conversation
The builders validate a JSON-shaped object once and raise OscalBuilderError (a ValueError, not an OscalParseError) instead of pydantic.ValidationError. make_resource takes a key that gives the UUID version 5 identifier. make_hash accepts an algorithm string that is not a named algorithm. The conformance runner runs the build-hash, build-rlink, and build-resource operations. BREAKING CHANGE: code that catches pydantic.ValidationError from a builder must catch OscalBuilderError or ValueError. Closes #53 Closes #62 Refs #63
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
OscalBuilderError(ValueError). It is not anOscalParseError. Each builder raises it for each invalid input, witherrorsentries and theValidationErroras__cause__.make_resource(key=...): a key and nouuidgive the UUID version 5 of the key (BMB-004). An empty key, a non-string key, or a key with auuidraisesOscalBuilderError.model_validatecall, so an item made withmodel_constructis validated.make_hashaccepts an algorithm string that is not a named algorithm (SHA-999), and rejectsSHA-256(BMB-001).build-hash,build-rlink, andbuild-resource, and maps the new class tobuilder-error. 13 expected failures and the xfail oftest_every_category_is_mappedare removed.build-resource/invalid-document-idstays a strict expected failure, now tracked by Post-processor removes pattern= from string fields whose context has the text 'int' #77.error-testsspec has the builder-error category.BREAKING: code that catches
pydantic.ValidationErrorfrom a builder must catchOscalBuilderErrororValueError.Closes #53. Closes #62. Refs #63 (only the
facadeoperation stays open).Benchmarks (median of 7, Python 3.14.8, pydantic 2.14.2)
The change does not touch these paths. The unchanged
pydantic_core.to_jsonrow moved about 3%, like the others, so I read it as run-to-run noise.PERFORMANCE.mdis unchanged.parse_oscal(bytes)serialize_oscal(doc, indent=None)serialize_oscal(doc)doc.model_dump_json()pydantic_core.to_json(doc)Memory peaks (
bench_memory.py) are identical before and after.Verification
hatch run releasepasses, andmodels.pyhas no drift.openspec validate add-builder-error-and-resource-key --strictpassed before archive.