Skip to content

[v3-2-test] Return 400 instead of 500 from materialize_asset for invalid validation input (#67445)#67526

Merged
pierrejeambrun merged 1 commit into
apache:v3-2-testfrom
jason810496:backport-0120ba7-v3-2-test
May 27, 2026
Merged

[v3-2-test] Return 400 instead of 500 from materialize_asset for invalid validation input (#67445)#67526
pierrejeambrun merged 1 commit into
apache:v3-2-testfrom
jason810496:backport-0120ba7-v3-2-test

Conversation

@jason810496

@jason810496 jason810496 commented May 26, 2026

Copy link
Copy Markdown
Member

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. (cherry picked from commit 0120ba7)

… 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.
(cherry picked from commit 0120ba7)

Co-authored-by: Deepak kumar <deepakkumar@meta.com>
@jason810496 jason810496 force-pushed the backport-0120ba7-v3-2-test branch from f2ca603 to 510dd46 Compare May 26, 2026 08:05
@pierrejeambrun pierrejeambrun merged commit 522e916 into apache:v3-2-test May 27, 2026
110 checks passed
vatsrahul1001 pushed a commit that referenced this pull request May 29, 2026
… invalid validation input (#67445) (#67526)

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.
(cherry picked from commit 0120ba7)

Co-authored-by: Deepak kumar <deepakkumar@meta.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:API Airflow's REST/HTTP API

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants