Commit 014750b
authored
fix(strict_schema): correct error message and replace runtime assert
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.1 parent d9f1d5f commit 014750b
1 file changed
+3
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
60 | | - | |
| 60 | + | |
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
| |||
154 | 154 | | |
155 | 155 | | |
156 | 156 | | |
157 | | - | |
158 | | - | |
159 | | - | |
| 157 | + | |
| 158 | + | |
160 | 159 | | |
161 | 160 | | |
162 | 161 | | |
| |||
0 commit comments