Eason09053360 opened a new pull request, #73453:
URL: https://github.com/apache/airflow/pull/73453

   ## Why
   
   `BulkBody.actions` picks its variant with a callable `Discriminator`, which 
pydantic hands the
   raw, unvalidated input and whose exceptions it does not wrap. 
`_action_discriminator` indexed
   that input with `action["action"]`, so a malformed entry escaped as 
`TypeError`, `KeyError` or
   `ValueError` rather than a validation error, and all five bulk endpoints 
(variables, pools,
   connections, Dag runs, task instances) answered a client-side typo with a 
500 and a traceback
   in the API server log.
   
   ## What
   
   - `core_api/datamodels/common.py`: read the tag from a mapping key or an 
attribute and return
     `None` for anything unrecognised, so the caller gets a 422 whose message 
names the accepted
     tags instead of leaking `_action_discriminator()`.
   - Guard mirrors the sibling `_asset_expression_discriminator` in the same 
file, but accepts any
     `Mapping` so previously working shapes keep working.
   - `tests/.../datamodels/test_common.py`: seven malformed payloads and an 
already-built action
     instance, none of which pass without the fix.
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   - [X] Yes — Claude Code (Opus 5)
   
   Generated-by: Claude Code (Opus 5) following [the 
guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)
   


-- 
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]

Reply via email to