fix: catch AttributeError in validate_data to allow Union fallthrough for non-DataFrame inputs (#993)
Some checks are pending
Bump Version / Bump Version Workflow (push) Waiting to run
CodeQL Advanced / Analyze (actions) (push) Waiting to run
CodeQL Advanced / Analyze (python) (push) Waiting to run
docker-build / platform-excludes (push) Waiting to run
docker-build / build (push) Blocked by required conditions
docker-build / merge (push) Blocked by required conditions
pre-commit / pre-commit (push) Waiting to run
Run Pytest on Pull Request / test (push) Waiting to run

* fix: catch AttributeError in validate_data for non-DataFrame Union types

PUT /v1/prediction/import/{provider_id} crashed with AttributeError
when Union validator tried PydanticDateTimeDataFrame validation on
scalar float/int values. Instead of falling through to DateTimeData
or dict, the exception propagated as 500. Fixes #992.

* fix: correct indentation of ValueError in validate_data

---------

Co-authored-by: Normann <github@koldrack.com>
This commit is contained in:
thefechner
2026-04-05 21:58:47 +02:00
committed by GitHub
parent afe85c31df
commit 8c7f7f321d

View File

@@ -1023,7 +1023,12 @@ class PydanticDateTimeDataFrame(PydanticBaseModel):
return v
# Validate consistent columns
columns = set(next(iter(v.values())).keys())
try:
columns = set(next(iter(v.values())).keys())
except AttributeError:
raise ValueError(
"Data values must be dicts (DataFrame format), not scalars. Use DateTimeData or DateTimeSeries format instead."
)
if not all(set(row.keys()) == columns for row in v.values()):
raise ValueError("All rows must have the same columns")