Skip to content

feat: validate remote manifest against local schema at runtime#2873

Open
mvanhorn wants to merge 1 commit into
sherlock-project:masterfrom
mvanhorn:feat/2613-validate-manifest-schema
Open

feat: validate remote manifest against local schema at runtime#2873
mvanhorn wants to merge 1 commit into
sherlock-project:masterfrom
mvanhorn:feat/2613-validate-manifest-schema

Conversation

@mvanhorn
Copy link
Copy Markdown

@mvanhorn mvanhorn commented Apr 4, 2026

Summary

Adds optional schema validation for the remote manifest in SitesInformation.__init__ (sherlock_project/sites.py). When jsonschema is installed, the fetched remote data.json is validated against the local data.schema.json before processing. If validation fails, sherlock prints a warning and falls back to the local manifest (same behavior as --local).

When jsonschema is not installed (standard pip users), validation is skipped entirely -- no behavior change, no new dependency.

Changes

  • sherlock_project/sites.py: Added conditional jsonschema import with _HAS_JSONSCHEMA flag. After loading remote JSON (before $schema pop), validate against the local schema file. On ValidationError, reload from the packaged local data.json.
  • tests/test_manifest.py: Added test_schema_validation_fallback (verifies invalid manifest raises on direct load) and test_schema_validation_passes_valid_manifest (verifies the current manifest validates cleanly).

Context

ppfeister described this in #2613: "validates against the local .schema file, and if validation fails, simply fails gracefully with a notice or defers to the local manifest as if --local were used." The goal is that older sherlock versions degrade gracefully when the remote manifest schema evolves.

I noticed PR #2614 has been open for 6 months without review. This implementation takes a different approach by making jsonschema optional at runtime (try/except import) rather than requiring it as a runtime dependency, since it's currently dev-only in pyproject.toml.

Testing

All existing + new tests pass (pytest tests/test_manifest.py -- 6/6 passed).

Fixes #2613

This contribution was developed with AI assistance (Claude Code).

When jsonschema is available, validate the fetched remote manifest
against the local data.schema.json before processing. If validation
fails, fall back to the local manifest with a warning. When
jsonschema is not installed (standard pip users), validation is
skipped so there is no behavior change.

This contribution was developed with AI assistance (Claude Code).
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.

Validate remote manifest against local schema before running

1 participant