Skip to content

Don't overwrite a profile's published shaclShapes when validating transform outputs - #103

Merged
avillar merged 2 commits into
masterfrom
fix-profile-shacl-overwrite
Oct 26, 2026
Merged

avillar merged 2 commits into
masterfrom
fix-profile-shacl-overwrite

Conversation

@rob-metalinkage

Copy link
Copy Markdown
Collaborator

Summary

Fixes #100: a register whose transforms validate their outputs against its own blocks (outputs.profiles) published those blocks' shaclShapes as working-directory-relative paths. Every register that imported them then failed. In ogcapi-sosa's case the published register.json had entries like this:

ogc.sosa.properties.observation → _sources/properties/observation/shapes.shacl

A downstream register then failed with:

Error processing _sources/csdm/features/CSD/_sources/properties/observation/shapes.shacl: [Errno 2] No such file or directory

That's because a relative entry is resolved against the importing bblock's own directory.

Cause: RdfValidator.__init__ writes the bblock's resolved inherited shapes back into bblock.metadata['shaclShapes'], as paths relative to the working directory, for postprocess to turn into URLs. validate_transform_output() also builds an RdfValidator for the output profile. That profile has usually been processed already, with its published shaclShapes made absolute, so the write-back replaced them with relative paths after the fact.

Change:

  • RdfValidator takes publish_shacl_shapes: bool = True.
  • validate_transform_output() passes False.
  • Validation itself is unchanged: the shapes are still loaded for the validator's own graphs.

Testing

  • New tests in tests/test_validate.py. They check that validate_transform_output() builds RdfValidator with publish_shacl_shapes=False, and that RdfValidator leaves shaclShapes untouched when it's False and writes them when it's True. The new tests fail without the fix.
  • Full suite inside the bblocks-postprocess:latest image venv, with pytest and pytest-mock installed: 181 passed.
  • End to end: I built a copy of an ogcapi-sosa fork with spec-example transforms that validate against the sosa property blocks, with this branch's ogc/ mounted over the image's /src/ogc.
    • 47/47 blocks pass, and no shaclShapes entry is relative.
    • Before the fix, the same build published relative paths for observation, execution, actuation, sampling and observationCollection.
    • Transform-output profile validation still ran: 212 passed and 2 failed, the same counts and the same two files as the unpatched build.

🤖 Generated with Claude Code

rob-metalinkage and others added 2 commits October 26, 2026 10:47
…nsform outputs

RdfValidator writes the bblock's resolved inherited SHACL shapes, as
working-directory-relative paths, back into bblock.metadata for postprocess
to make absolute. validate_transform_output() also builds an RdfValidator for
the transform's output profile, which may already have been processed, so
its published shaclShapes were replaced with relative paths
(e.g. _sources/properties/observation/shapes.shacl). Registers importing it
then resolved those against their own bblocks and failed to load them.

RdfValidator takes publish_shacl_shapes (default True);
validate_transform_output() passes False.

Fixes #100

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Record RdfValidator kwargs with a dedicated fake instead of indexing into the
validator list, and assert the exact relative shapes path written when
publish_shacl_shapes is true.
@avillar
avillar marked this pull request as ready for review October 26, 2026 21:50
@avillar
avillar self-requested a review as a code owner October 26, 2026 21:50
@avillar
avillar merged commit 8620529 into master Oct 26, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Transform output profile validation rewrites profile block's shaclShapes to cwd-relative paths in register.json

2 participants