You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Schema guard json_mode flag is silently ignored #1999
The Schema guard's docstring documents json : bool — "If True, just verify the output is parseable JSON", but the constructor parameter is actually named json_mode and is stored as self._json_mode without ever being read. evaluate() always parses JSON and always applies schema validation.
Reproduction
fromopenlit.guard.schemaimportSchemaSchema(action="deny", json=True) # TypeError: unexpected keyword 'json'Schema(action="deny", json_mode=True, schema={"type": "integer"}).evaluate('"hello"')
# returns schema_mismatch/DENY although the output is parseable JSON
Expected
The documented parameter name works, and when it is true a parseable JSON output passes (invalid JSON is still rejected). The default schema-validation behavior is unchanged.
Proposed fix
Align the docstring with json_mode and honor the flag in evaluate() with an early ALLOW after successful parsing.
Activity