wiasliaw opened a new pull request, #73886: URL: https://github.com/apache/airflow/pull/73886
## Why - `google.auth.load_credentials_from_file` returns `str | None` for the project id, but `_CredentialProvider._get_credentials_using_credential_config_file` is annotated `-> tuple[Credentials, str]` and passed the `None` through unchanged. - The other two branches that can hit this already normalize: ADC since #61654, IdP since #72799. This was flagged as an optional follow-up in the review of #72799 — the plain `credential_config_file` branch was the last one handing back `None` despite its `str` annotation. - Behaviour is unchanged for consumers: every caller gates on truthiness (`GoogleBaseHook` overrides with the connection's `project` extra and `fallback_to_default_project_id` raises when nothing provides a project id), so `""` and `None` take identical paths. The fix makes the actual return type match the declared one and keeps the three branches consistent. ## How - Normalize a falsy project id to `""` before the shared return in `_get_credentials_using_credential_config_file`, same pattern as the ADC and IdP branches. - Add `test_get_credentials_using_credential_config_file_no_project_id`, which mocks `google.auth.load_credentials_from_file` returning a `None` project id and asserts the provider returns `""`. The credentials mock uses `mock.create_autospec(Credentials, instance=True)` per the review suggestion on #72799. related: #72799, #61654 ## Verification - `uv run --project providers/google pytest providers/google/tests/unit/google/cloud/utils/test_credentials_provider.py` — 45 passed. - The new test fails without the source change (returns `None` instead of `""`). - `ruff format` and `ruff check` pass on both changed files. --- ##### Was generative AI tooling used to co-author this PR? - [X] Yes - Claude Code Generated-by: Claude Code (Fable 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]
