Skip to content

Normalize empty project id in credential config file branch - #73886

Merged
shahar1 merged 1 commit into
apache:mainfrom
wiasliaw:normalize-credential-config-file-project-id
Oct 31, 2026
Merged

shahar1 merged 1 commit into
apache:mainfrom
wiasliaw:normalize-credential-config-file-project-id

Conversation

@wiasliaw

Copy link
Copy Markdown
Contributor

Why

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 Fix Google IdP credentials failing when project id cannot be resolved #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?
  • Yes - Claude Code

Generated-by: Claude Code (Fable 5) following the guidelines

google-auth's load_credentials_from_file returns `str | None` for the
project id, but _get_credentials_using_credential_config_file is
annotated `-> tuple[Credentials, str]` and could hand `None` back to
callers. The ADC branch (apache#61654) and the IdP branch (apache#72799) already
normalize a missing project id to an empty string so the consumer
decides how to handle it; this makes the third and last branch
consistent with them, as suggested in the review of apache#72799.
@wiasliaw
wiasliaw requested a review from shahar1 as a code owner September 29, 2026 08:09
@boring-cyborg boring-cyborg Bot added area:providers provider:google Google (including GCP) related issues labels Sep 29, 2026
@molcay

molcay commented Sep 29, 2026

Copy link
Copy Markdown
Contributor

Hi @wiasliaw,

Thank you for your PR!

In the google provider side, we want to also see the system tests results after a change.
Did you also run the system tests which are using the credentials in a way that you fixed?
If so, please share your results as well.

Thank you in advance!

@wiasliaw

Copy link
Copy Markdown
Contributor Author

Hi, @molcay

@shahar1 shahar1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Brings the plain credential_config_file branch in line with the ADC and IdP branches: a None project id from google.auth.load_credentials_from_file is now normalised to "", so the return value matches the declared tuple[Credentials, str]. I checked the callers (GoogleBaseHook, the Secret Manager backend, the GCS/Cloud Logging task handlers): all of them test the project id for truthiness, so behaviour is unchanged, and the new test covers the string-config path that previously returned None.


This review was drafted by an AI-assisted tool and
confirmed by an Apache Airflow maintainer. The maintainer
approving this PR has read the findings and signed off. If
something feels off, please reply on the PR and a maintainer
will follow up.

More on how Apache Airflow handles maintainer review:
Contributing guide.

@shahar1
shahar1 merged commit 161cff0 into apache:main Oct 31, 2026
86 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:providers provider:google Google (including GCP) related issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants