fix: Add extra='forbid' to Condition for proper Union resolution
Critical fix: Without extra='forbid', Pydantic accepted UI format
{operator: "and", operands: [...]} as valid Condition by ignoring
unknown fields, resulting in Condition(expression=None).
With extra='forbid':
- Condition rejects unknown fields → fails
- Union tries next type → LogicExpression → success
Test Results (9/9 passed):
- Simple comparisons (eq, neq, gt, lt, in) ✅
- AND/OR combinations ✅
- Deep nesting (3+ levels) ✅
- NOT operator ✅
- All operators (eq, neq, in, not_in, gt, lt, gte, lte, and, or, not) ✅
- Legacy format (Condition wrapper) ✅
- Complex real-world scenarios ✅
Added comprehensive test suite in:
- test_condition_parsing.py (9 test cases)
- test_condition_union.py (Union resolution verification)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
f5ce1ec941
commit
ba04e0c0b6
3 files changed
+365
No files matched your search
@@ -162,7 +162,13 @@ class Condition(BaseModel):
|
||||
Bedingung für einen Logik-Knoten.
|
||||
|
||||
Unterstützt if/else-if/else-Logik.
|
||||
|
||||
Note: Uses extra='forbid' to ensure proper Union resolution with LogicExpression.
|
||||
If unknown fields are present (like 'operator', 'operands'), deserialization fails
|
||||
and Pydantic tries LogicExpression instead.
|
||||
"""
|
||||
model_config = {'extra': 'forbid'}
|
||||
|
||||
type: str = Field(default="if", description="Bedingungstyp: if, else-if, else")
|
||||
expression: Optional[LogicExpression] = Field(None, description="Logischer Ausdruck (null bei 'else')")
|
||||
then_path: Optional[str] = Field(None, description="Edge-ID für 'then'-Pfad")
|
||||
|
||||
Reference in new issue
Block a user