Skip to content

Commit

Permalink
API: Fixed internal error on malformed datapoint.
Browse files Browse the repository at this point in the history
  • Loading branch information
xsedla1o committed Aug 2, 2023
1 parent 1cc4d4c commit 8bf78ad
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions dp3/api/internal/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,12 @@ def validate_t2(cls, v, values):
assert t1 <= v, "'t2' is before 't1'"
return v

@root_validator
@root_validator(skip_on_failure=True)
def validate_against_attribute(cls, values):
# Try to convert API datapoint to DP3 datapoint
api_to_dp3_datapoint(values)
try:
api_to_dp3_datapoint(values)
except KeyError as e:
raise ValueError(f"Missing key: {e}") from e

return values

0 comments on commit 8bf78ad

Please sign in to comment.