fix(schemas): wrap LocalSchemaProvider JSON read in SchemaError#9
Merged
j-s-135 merged 1 commit intoJun 26, 2026
Merged
Conversation
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>
Collaborator
|
Thanks, Clemens. Tested and working. |
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.
Problem
LocalSchemaProvider.get_schema(src/onedep_lib/schemas/local.py) callsjson.loadwith no error handling, so a corrupted cached schema file raisesjson.JSONDecodeErrorrather than theSchemaErrortheSchemaProvidercontract promises.
RemoteSchemaProvider(src/onedep_lib/schemas/remote.py)already wraps parse failures as
SchemaError, so callers that handle bothproviders uniformly are surprised by the local one.
Fix
Wrap the read in
try/except (ValueError, OSError)and re-raise asSchemaError, matching the remote provider's behaviour.Test
Adds
tests/schemas/test_local.pycovering: a cache hit, a missing schema, anda corrupted-JSON file surfacing as
SchemaError. Full suite green (146 passed).