fix(variables): accept JSON string and empty input for json_schema#165
Merged
WH-2099 merged 3 commits intoJun 2, 2026
Merged
Conversation
VariableEntity.json_schema previously only accepted dict/None, but the frontend code editor persists the schema as raw JSON text, and clearing the schema sends an empty string instead of dropping the field. Both cases triggered validation errors. This change switches validate_json_schema to mode="before" so it can: parse JSON strings, treat None/"" as "no schema", and reject non-object inputs with a clear message. Adds tests covering dict / JSON string / empty / invalid JSON / non-object / semantically invalid schema cases. Refs langgenius#164
|
All contributors on this pull request have signed the CLA. |
Contributor
Author
|
I have read the CLA Document and I hereby sign the CLA |
WH-2099
approved these changes
Jun 2, 2026
Member
WH-2099
left a comment
There was a problem hiding this comment.
Reviewed locally; no blocking issues found.
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.
Important
!Related Issue
Closes #164
Summary
VariableEntity.json_schemapreviously only accepteddict | None. However:backend receives a string and validation fails.
""instead of dropping the field,which also fails validation even though the user intent is "no schema".
Changes
validate_json_schemais switched tomode="before"so it can pre-processthe raw input.
ValueErrorwhen the string is not valid JSON.
Noneand""uniformly as "no schema" and returnNone.Draft7Validator.check_schema(...)semantic validation is kept.Tests
Adds
tests/variables/test_input_entities.pycovering:Noneinput →None""input →NoneValidationError123) →ValidationErrorValidationErrorNo public API or behavior is broken for callers that were already passing
dict | None.Checklist
!