1fanwang opened a new pull request, #72907: URL: https://github.com/apache/airflow/pull/72907
The Execution API routes validate_inlets_and_outlets and set_task_state_store raised unhandled AttributeError and ValueError exceptions when a task instance had no associated DagRun in the metadata database. These exceptions escaped to the application handler and returned opaque HTTP 500 responses. This change catches the missing DagRun condition in both endpoints and returns a 404 Not Found response with structured RFC 9457 details, matching the error handling in pull request 72890. related: #72890 # Testing Done Reproduction before fix: ```bash uv run --project airflow-core pytest airflow-core/tests/unit/api_fastapi/execution_api/versions/head/test_task_state_store.py -k test_put_missing_dagrun_returns_404 uv run --project airflow-core pytest airflow-core/tests/unit/api_fastapi/execution_api/versions/head/test_task_instances.py -k test_validate_inlets_and_outlets_missing_dagrun_returns_404 ``` Pre-fix output: ```text FAILED test_task_state_store.py test_put_missing_dagrun_returns_404 - ValueError: No DagRun found for dag_id='dag' run_id='test' FAILED test_task_instances.py test_validate_inlets_and_outlets_missing_dagrun_returns_404 - AttributeError: 'NoneType' object has no attribute 'bundle_version' ``` Verification after fix: ```bash uv run --project airflow-core pytest airflow-core/tests/unit/api_fastapi/execution_api/versions/head/test_task_state_store.py airflow-core/tests/unit/api_fastapi/execution_api/versions/head/test_task_instances.py -k "test_validate_inlets_and_outlets or test_put_missing_dagrun" ``` Post-fix output: ```text ================ 2 passed, 230 deselected, 2 warnings in 6.29s ================= ``` <details> <summary>Raw logs</summary> ```text test_task_state_store.py test_put_missing_dagrun_returns_404 PASSED [ 50%] test_task_instances.py test_validate_inlets_and_outlets_missing_dagrun_returns_404 PASSED [100%] ``` </details> -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
