per-andersen opened a new pull request, #74472:
URL: https://github.com/apache/airflow/pull/74472

   `dag.test()` fails for any task whose `task_id` contains a non-ASCII 
character (for example `Købsmoms`) as soon as the task pushes an XCom, even 
though `validate_key` accepts these ids.
   
   `dag.test()` serves the Execution API in-process: the Task SDK client talks 
to a2wsgi's `ASGIMiddleware` through `httpx.WSGITransport`. httpx puts the 
percent-decoded path into `PATH_INFO` as a plain `str`, while a2wsgi follows 
PEP 3333 and decodes `PATH_INFO` as UTF-8 bytes carried in a latin-1 string. A 
non-ASCII path segment therefore fails in `a2wsgi.asgi.build_scope`, with 
`UnicodeDecodeError` for characters such as `ø` and `UnicodeEncodeError` for 
characters outside Latin-1 such as `タ`.
   
   This PR wraps the middleware in `InProcessExecutionAPI.transport` so that 
`PATH_INFO` and `SCRIPT_NAME` are re-encoded to PEP 3333 form before they reach 
a2wsgi. Only in-process execution is affected; over a real HTTP connection the 
ASGI server decodes the path correctly.
   
   closes: #74469
   
   Testing:
   
   - New unit test `test_in_process_execution_api_handles_non_ascii_path`, 
which fails on `main` and passes with this change.
   - Ran the reproduction from the issue with `dag.test()` in Breeze: on `main` 
the XCom push fails with `UnicodeDecodeError` and the Dag run fails; with this 
change the Dag run succeeds.
   - `prek` pre-commit and manual stages pass for the changed files.
   
   ##### Was generative AI tooling used to co-author this PR?
   
   <!--
   If generative AI tooling has been used in the process of authoring this PR, 
please
   change below checkbox to `[X]` followed by the name of the tool, uncomment 
the "Generated-by".
   -->
   
   - [X] Yes (please specify the tool below)
   
   Generated-by: Claude Code (Opus 5.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