Commit 0120ba7
authored
API: Return 400 instead of 500 from materialize_asset for invalid validation input (apache#67445)
The materialize_asset POST endpoint passed user input (dag_run_id,
logical_date/data_interval pairing, partition_key) straight through to
MaterializeAssetBody.validate_context() and dag.create_dagrun(), which raise
ValueError / ParamValidationError on invalid input (e.g. dag_run_id containing
'..', invalid partition_key type, logical_date/data_interval mismatch). Those
exceptions escaped uncaught and were returned as 500 Internal Server Error,
even though the route's OpenAPI spec already documents 400 for this case.
Wrap the validate_context / create_dagrun calls in try/except and re-raise as
HTTPException(400) with the validator's message in the detail, matching the
sibling pattern in dag_run.trigger_dag_run.
Regression test asserts dag_run_id='bad..id' returns 400, not 500.1 parent 896c031 commit 0120ba7
2 files changed
Lines changed: 32 additions & 15 deletions
File tree
- airflow-core
- src/airflow/api_fastapi/core_api/routes/public
- tests/unit/api_fastapi/core_api/routes/public
Lines changed: 19 additions & 15 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
| 76 | + | |
76 | 77 | | |
77 | 78 | | |
78 | 79 | | |
| |||
443 | 444 | | |
444 | 445 | | |
445 | 446 | | |
446 | | - | |
447 | | - | |
448 | | - | |
449 | | - | |
450 | | - | |
451 | | - | |
452 | | - | |
453 | | - | |
454 | | - | |
455 | | - | |
456 | | - | |
457 | | - | |
458 | | - | |
459 | | - | |
460 | | - | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
461 | 465 | | |
462 | 466 | | |
463 | 467 | | |
| |||
Lines changed: 13 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1609 | 1609 | | |
1610 | 1610 | | |
1611 | 1611 | | |
| 1612 | + | |
| 1613 | + | |
| 1614 | + | |
| 1615 | + | |
| 1616 | + | |
| 1617 | + | |
| 1618 | + | |
| 1619 | + | |
| 1620 | + | |
| 1621 | + | |
| 1622 | + | |
| 1623 | + | |
| 1624 | + | |
1612 | 1625 | | |
1613 | 1626 | | |
1614 | 1627 | | |
| |||
0 commit comments