From b5121790d64dc963d7f1f56b1bbdabcbef3ac09b Mon Sep 17 00:00:00 2001 From: Tal Date: Wed, 25 Sep 2024 09:10:30 +0300 Subject: [PATCH] fix(api): schema validation problem in mapping rule in dto (#1995) --- keep/api/models/db/mapping.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/keep/api/models/db/mapping.py b/keep/api/models/db/mapping.py index 2f0e0ab79..64970c75a 100644 --- a/keep/api/models/db/mapping.py +++ b/keep/api/models/db/mapping.py @@ -60,8 +60,8 @@ class MappingRuleDtoOut(MappRuleDtoBase, extra="ignore"): class MappingRuleDtoIn(MappRuleDtoBase): rows: Optional[list[dict]] = None - @validator("type", pre=True, always=True) - def validate_type(cls, _type, values): - if _type == "csv" and not values.get("rows"): + @validator("rows", pre=True, always=True) + def validate_rows(cls, rows, values): + if not rows and values.get("type") == "csv": raise ValueError("Mapping of type CSV cannot have empty rows") - return _type + return rows