Skip to content

fix(schemas): wrap LocalSchemaProvider JSON read in SchemaError#9

Merged
j-s-135 merged 1 commit into
wwPDB:developfrom
CV-GPhL:fix/local-schema-provider-error-contract
Jun 26, 2026
Merged

fix(schemas): wrap LocalSchemaProvider JSON read in SchemaError#9
j-s-135 merged 1 commit into
wwPDB:developfrom
CV-GPhL:fix/local-schema-provider-error-contract

Conversation

@CV-GPhL

@CV-GPhL CV-GPhL commented Jun 22, 2026

Copy link
Copy Markdown

Problem

LocalSchemaProvider.get_schema (src/onedep_lib/schemas/local.py) calls
json.load with no error handling, so a corrupted cached schema file raises
json.JSONDecodeError rather than the SchemaError the SchemaProvider
contract promises. RemoteSchemaProvider (src/onedep_lib/schemas/remote.py)
already wraps parse failures as SchemaError, so callers that handle both
providers uniformly are surprised by the local one.

Fix

Wrap the read in try/except (ValueError, OSError) and re-raise as
SchemaError, matching the remote provider's behaviour.

Test

Adds tests/schemas/test_local.py covering: a cache hit, a missing schema, and
a corrupted-JSON file surfacing as SchemaError. Full suite green (146 passed).

A corrupted cached schema made get_schema raise json.JSONDecodeError, while
callers and RemoteSchemaProvider expect SchemaError. Wrap the json.load in
try/except (ValueError/OSError) and re-raise as SchemaError so both providers
honour the same contract.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@j-s-135

j-s-135 commented Jun 26, 2026

Copy link
Copy Markdown
Collaborator

Thanks, Clemens. Tested and working.

@j-s-135 j-s-135 merged commit 1636ec3 into wwPDB:develop Jun 26, 2026
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.

2 participants