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

   The SimpleAuthManager tests under 
`airflow-core/tests/unit/api_fastapi/auth/managers/simple/` all share a single 
generated-password file path under `AIRFLOW_HOME` 
(`simple_auth_manager_passwords.json.generated`). Several fixtures and tests 
create, overwrite, and delete that file — notably the `auth_manager` conftest 
fixture (`os.remove`), `test_init_with_all_admins`, and `test_get_passwords`.
   
   Because the path is global, under parallel (xdist) runs one worker process 
can delete the file while another is mid-read on it. 
`SimpleAuthManager.get_passwords()` opens the file with `"r+"` and fails hard 
if it is missing, so e.g. `test_create_token_invalid_user_password` 
intermittently raises:
   
   ```
   FileNotFoundError: [Errno 2] No such file or directory: 
'.../simple_auth_manager_passwords.json.generated'
   ```
   
   This is a long-standing latent test-isolation bug (the shared-path fixture 
dates back to the sources-move in #47798), surfaced when these test types run 
together in the same parallel pool.
   
   **Fix:** isolate the password file per test via an autouse fixture that 
points the existing `[core] simple_auth_manager_passwords_file` config option 
at a per-test `tmp_path`. Each test (and each xdist worker) gets its own file, 
removing the cross-process race. No source change needed — the source already 
honors that config option.
   
   Verified by reproducing the failure (~1-in-5 parallel runs before) and 
confirming 10/10 clean parallel runs of the whole directory after the fix.
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   - [X] Yes — Claude Code (Opus 4.8)
   
   Generated-by: Claude Code (Opus 4.8) 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