Skip to content

Fix Vertex AI hook silently discarding credentials when vertexai flag is set - #72012

Merged
Lee-W merged 1 commit into
apache:mainfrom
astronomer:fix-common-ai-vertex-mode-flag
Aug 24, 2026
Merged

Lee-W merged 1 commit into
apache:mainfrom
astronomer:fix-common-ai-vertex-mode-flag

Conversation

@Lee-W

@Lee-W Lee-W commented Aug 23, 2026

Copy link
Copy Markdown
Member

Setting "vertexai": true/false in the PydanticAIVertexHook connection extra made the provider constructor call raise TypeError, since neither GoogleProvider nor GoogleCloudProvider in the currently pinned pydantic-ai accept a vertexai constructor kwarg anymore (that distinction moved to a dedicated provider class upstream). The base hook's TypeError fallback then silently re-resolved credentials from environment variables only, discarding project/location/ service_account_info/api_key with just a WARNING log line as a hint.

The field is now accepted but never forwarded to the provider constructor, so the rest of the explicit credentials still apply.


Was generative AI tooling used to co-author this PR?
  • Yes (please specify the tool below)

Generated-by: [Tool Name] following the guidelines


  • Read the Pull Request Guidelines for more information. Note: commit author/co-author name and email in commits become permanently public when merged.
  • For fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
  • When adding dependency, check compliance with the ASF 3rd Party License Policy.
  • For significant user-facing changes create newsfragment: {pr_number}.significant.rst, in airflow-core/newsfragments. You can add this file in a follow-up commit after the PR is created so you know the PR number.

@ColtenOuO ColtenOuO 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.

Thanks! Just noticed a minor thing here:

In pydantic_ai.py:466 -- The class docstring's example JSON (Connection fields section) still includes "vertexai": true here, but the prose right below it (lines 472-473 in this PR's diff) now says the field has no effect.

Since the get_ui_field_behaviour() placeholder a few lines down (line 492) was already updated to drop vertexai, could this example be updated the same way so the two don't contradict each other?

… is set

Setting "vertexai": true/false in the PydanticAIVertexHook connection
extra made the provider constructor call raise TypeError, since neither
GoogleProvider nor GoogleCloudProvider in the currently pinned
pydantic-ai accept a vertexai constructor kwarg anymore (that
distinction moved to a dedicated provider class upstream). The base
hook's TypeError fallback then silently re-resolved credentials from
environment variables only, discarding project/location/
service_account_info/api_key with just a WARNING log line as a hint.

The field is now accepted but never forwarded to the provider
constructor, so the rest of the explicit credentials still apply.
@Lee-W
Lee-W force-pushed the fix-common-ai-vertex-mode-flag branch from 30c12ac to afc0194 Compare August 24, 2026 08:07
@Lee-W

Lee-W commented Aug 24, 2026

Copy link
Copy Markdown
Member Author

Thanks! Just noticed a minor thing here:

In pydantic_ai.py:466 -- The class docstring's example JSON (Connection fields section) still includes "vertexai": true here, but the prose right below it (lines 472-473 in this PR's diff) now says the field has no effect.

Since the get_ui_field_behaviour() placeholder a few lines down (line 492) was already updated to drop vertexai, could this example be updated the same way so the two don't contradict each other?

Good catch! Just updated it

@ColtenOuO ColtenOuO 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.

LGTM : D

@Lee-W
Lee-W merged commit 98747f8 into apache:main Aug 24, 2026
84 checks passed
@Lee-W
Lee-W deleted the fix-common-ai-vertex-mode-flag branch August 24, 2026 12:00
Lee-W added a commit to astronomer/airflow that referenced this pull request Aug 25, 2026
…test

The Vertex hook's tests still built their connection extras from
"google-vertex:gemini-2.0-flash", a provider id pydantic-ai no longer
recognizes -- it was renamed to "google-cloud:" when GoogleProvider(vertexai=True)
was split into GoogleProvider and GoogleCloudProvider
(pydantic/pydantic-ai#5336). The user-facing strings were corrected in apache#72012,
but the fixtures kept exercising a prefix that raises "Unknown provider" in
real use, so nothing in the suite would notice the documented example drifting
away from a working one again.

Align the fixtures with the prefix the hook now documents and add a test that
resolves it through pydantic-ai's own provider lookup rather than a mock.
Lee-W added a commit to astronomer/airflow that referenced this pull request Aug 27, 2026
…test

The Vertex hook's tests still built their connection extras from
"google-vertex:gemini-2.0-flash", a provider id pydantic-ai no longer
recognizes -- it was renamed to "google-cloud:" when GoogleProvider(vertexai=True)
was split into GoogleProvider and GoogleCloudProvider
(pydantic/pydantic-ai#5336). The user-facing strings were corrected in apache#72012,
but the fixtures kept exercising a prefix that raises "Unknown provider" in
real use, so nothing in the suite would notice the documented example drifting
away from a working one again.

Align the fixtures with the prefix the hook now documents and add a test that
resolves it through pydantic-ai's own provider lookup rather than a mock.
Lee-W added a commit to astronomer/airflow that referenced this pull request Aug 27, 2026
…test

The Vertex hook's tests still built their connection extras from
"google-vertex:gemini-2.0-flash", a provider id pydantic-ai no longer
recognizes -- it was renamed to "google-cloud:" when GoogleProvider(vertexai=True)
was split into GoogleProvider and GoogleCloudProvider
(pydantic/pydantic-ai#5336). The user-facing strings were corrected in apache#72012,
but the fixtures kept exercising a prefix that raises "Unknown provider" in
real use, so nothing in the suite would notice the documented example drifting
away from a working one again.

Align the fixtures with the prefix the hook now documents and add a test that
resolves it through pydantic-ai's own provider lookup rather than a mock.
imrichardwu pushed a commit to imrichardwu/airflow that referenced this pull request Sep 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants