Skip to content

API: Translate domain ValueError to HTTPException in Asset State Store routes - #74179

Closed
Kaap10 wants to merge 2 commits into
apache:mainfrom
Kaap10:fix-asset-state-store-domain-exceptions
Closed

Kaap10 wants to merge 2 commits into
apache:mainfrom
Kaap10:fix-asset-state-store-domain-exceptions

Conversation

@Kaap10

@Kaap10 Kaap10 commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

Catch domain-level ValueErrors in asset_state_store route handlers and translate them to HTTP 400 Bad Request errors. Previously, these were unhandled and surfaced as HTTP 500 Internal Server Errors, leaking internal traces.

This implements the same exception translation pattern already established in task_state_store.py.


Was generative AI tooling used to co-author this PR?
  • Yes (Antigravity AI Assistant)

Generated-by: Antigravity following the guidelines


  • Read the Pull Request Guidelines for more information. Note: commit author/co-author name and email in commits become permanently public when merged.
  • For fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
  • When adding dependency, check compliance with the ASF 3rd Party License Policy.
  • For significant user-facing changes create newsfragment: {pr_number}.significant.rst, in airflow-core/newsfragments. You can add this file in a follow-up commit after the PR is created so you know the PR number.

…e routes

Catch domain-level ValueErrors in asset_state_store route handlers and translate them to HTTP 400 errors rather than allowing unhandled 500 Internal Server Errors.
@Kaap10

Kaap10 commented Oct 4, 2026

Copy link
Copy Markdown
Contributor Author

Hi Team,
This PR is ready for review. All core, DB (Postgres/MySQL/SQLite), and integration tests are passing cleanly.

The single failure in the Static checks job appears to be caused by a transient prek hook cache issue on the runner (insert_license: No such file or directory). Could a maintainer please trigger a quick re-run for that job when taking a look?

Thanks!

@fat-catTW fat-catTW left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work!

@pierrejeambrun pierrejeambrun left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for looking into this! Unless I'm missing something, I don't think these three calls can raise a ValueError today. The API route always writes with kind=API and no task fields, so validate_writer_fields and _build_asset_writer_fields never raise, and delete/clear on an AssetScope are plain DELETE statements. The new tests pass because the backend is mocked to raise errors that don't exist on these paths.

If you hit a 500 on one of these endpoints, could you share the request? That would tell us what actually needs handling. Otherwise I think this would mostly add a 400 to the public spec that clients can never get.

Closing until you can provide a way to reproduce.

kind=AssetStateStoreWriterKind.API,
session=session,
)
except ValueError as e:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With kind=API and no task or identity fields, I don't think set_asset_state_store can raise here. Also, task_state_store.py maps its ValueError (the missing DagRun) to a 404, not a 400, so the two wouldn't quite match anyway.

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.

3 participants