Skip to content

Conversation

@mshsheikh
Copy link
Contributor

This commit addresses two critical issues in the strict schema validation:

  1. Corrected error message for additionalProperties:

    • Changed the misleading error message from "additionalProperties should not be set" to "additionalProperties should be set to False"
    • This accurately reflects the requirement that object types must explicitly set additionalProperties: false rather than implying it shouldn't be set at all
    • Prevents confusion for users encountering this validation error
  2. Replaced dangerous assert with proper exception handling:

    • Replaced the assert is_dict(value) statement with proper runtime validation
    • Now raises a ValueError with clear message instead of relying on assert
    • Ensures validation works properly in optimized Python environments (when run with -O flag)
    • Maintains the same error semantics while making the code production-safe

Both fixes maintain backward compatibility while improving error clarity and runtime safety.

This commit addresses two critical issues in the strict schema validation:

1. **Corrected error message for additionalProperties**:
   - Changed the misleading error message from "additionalProperties should not be set" to "additionalProperties should be set to False"
   - This accurately reflects the requirement that object types must explicitly set `additionalProperties: false` rather than implying it shouldn't be set at all
   - Prevents confusion for users encountering this validation error

2. **Replaced dangerous assert with proper exception handling**:
   - Replaced the `assert is_dict(value)` statement with proper runtime validation
   - Now raises a `ValueError` with clear message instead of relying on `assert`
   - Ensures validation works properly in optimized Python environments (when run with `-O` flag)
   - Maintains the same error semantics while making the code production-safe

Both fixes maintain backward compatibility while improving error clarity and runtime safety.
@seratch
Copy link
Member

seratch commented Oct 17, 2025

I don't think the current error message here is incorrect.

@seratch seratch closed this Oct 17, 2025
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