Repository navigation
Module import resolution leaks raw exceptions for invalid declarations, lock records and policy files #1580
Copy link
Copy link
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Problem
Several values that module import resolution reads are checked by Pydantic or the OS but never translated into the SDL error envelope. They escape as raw ValidationError, RecursionError, yaml errors, UnicodeDecodeError or IsADirectoryError, and raes sdl resolve prints a traceback. ADR-076 §5 says import and model validation "must not leak a raw Pydantic ValidationError through parser or language-service entry points", and specs/sdl/diagnostics.md §7 and §8 forbid framework input renderings and trust-policy contents in diagnostics. Probed on dev a391904a (file:line on that commit, under implementations/python/packages):
resolve_lock_recordsvalidates each root import withImportDecl.model_validate(raes/module_registry/resolution.py:470). An import withversion: 1.0, a missing namespace, orversion: '>=banana'raises a rawValidationError, whileparse_sdl_filereports the same root asSDLParseErrorwith ansdl.model.invaliddiagnostic at/imports/0/....raes sdl resolve(raes_cli/sdl.py:67) then exits 1 with a traceback that rendersinput_value=1.0.resolve_lock_recordsacceptsimports: {}, an importversion: ''and a moduleversion: '', and writes a lockfile, althoughparse_sdl_filerejects all three. For the two blank versions,parse_sdl_fileraises a rawValidationErrorfromResolvedImportProvenance(raes/_composition_provenance.py:40) instead of a diagnostic.- A
locked:import whose lock record hasrequested_version: '>=banana'raises a rawValidationErrorfrom the delegatedImportDecl(raes/module_registry/resolution.py:200-206). A record whose ownsourceislocked:xand whoseresolved_sourceisx, imported aslocked:x, raisesRecursionError, because_resolve_locked_importhands the record's source back to itself (:207). An acyclic two-record chain resolves today. load_lockfileandload_trust_policy(raes/module_registry/models.py:85-86,:93) raise a rawValidationErrorfor invalid JSON or a wrong shape (for exampleregistries: [1]), ayaml.parser.ParserErrorfor bad YAML,UnicodeDecodeErrorfor a file that is not UTF-8, andIsADirectoryErrorfor a directory. These come throughparse_sdl_file, and the trust-policy cases also throughresolve_lock_records.- A local import that names a directory raises
IsADirectoryErrorthrough both entry points (raes/module_registry/resolution.py:224-226checks onlyexists()). - An imported unit with a removed scoring section (
metrics: {}) gets the generic "/metrics: Extra inputs are not permitted" diagnostic, because_reject_removed_scoring_sections(raes/parser.py:251, called at:377) runs only for the root. ADR-073 §5 gives removed scoring surfaces a pointer to their replacement. expand_sdl_modulescalled directly with an invalid declaration raises a rawValidationErrorfrom_import_decl(raes/composition/_expand.py:176-179, called at:252).
Scope
- Translate each failure above into the existing
SDLParseErrorenvelope through the existing bounded renderer (_model_parse_error), with no new exception type, model, schema or language change. Messages name the failed file or import and never render input values or OS error text. resolve_lock_recordsvalidates root import declarations and the provenance record it writes the same wayparse_sdl_filedoes, soraes sdl resolverejects only documentsparse_sdl_filealready rejects. The lockfile for a valid root is unchanged.- The rendering of
raes sdl verify-importserrors stays with Import verification ends in a traceback on a semantic error #1552. - The change is package code under
implementations/python/packages, which the research-evidence digest covers, so both research captures are republished in the same pull request.
Done when
-
resolve_lock_recordsandraes sdl resolvereport invalid root import declarations with the same code, pointer and range asparse_sdl_file, and reject the import sources and versions thatparse_sdl_filecannot record as provenance. A valid root still gives a byte-identical lockfile. - An invalid
locked:record, or alocked:chain that revisits a record, raisesSDLParseErrornamingraes.lock.json. It does not raiseValidationErrororRecursionError. Acyclic chains resolve as before. - An invalid, malformed, non-UTF-8 or directory
raes.lock.jsonorraes-trust.yamlraisesSDLParseErrorwith the file aspathand its name in the message, and never renders its values. - An import that names a directory gets an
SDLParseErrornaming the import, and an imported unit with a removed scoring section gets the root's ADR-073 message. -
expand_sdl_modulescalled directly reports an invalid declaration as a field diagnostic. -
raes sdl resolveexits non-zero and prints no traceback for each of these, naming the failing file. - Both research captures are republished.
Related
- Verify reusable and scenario-local behavior authoring (DSL-116) #297: its done-when was delivered by fix(sdl): complete reusable behavior authoring (DSL-116) #1426. This bug was found while reviewing fix(sdl): report lock, trust-policy and import-provenance failures as sdl diagnostics #1484 for Verify reusable and scenario-local behavior authoring (DSL-116) #297.
- fix(sdl): complete reusable behavior authoring (DSL-116) #1426 (validates the root and imported units through
parse_sdl_file) - Import verification ends in a traceback on a semantic error #1552 (
verify-importserror rendering) - fix(sdl): fetch oci modules from public registries through the anonymous token flow #1479 / fix(sdl): fetch oci modules from public registries through the anonymous token flow #1480 (OCI token flow in the same module)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working
Activity
chore(research): record research captures for issue #1580
chore(research): record research captures for issue #1580
chore(research): record research captures for issue #1580