Repository navigation
Validate the connection type in PydanticAIHook.get_hook - #74626
Merged
Lee-W merged 3 commits intoOct 14, 2026
Merged
Conversation
Lee-W
force-pushed
the
validate-connection-type-pydanticai-hook
branch
from
October 13, 2026 09:32
ba01399 to
5245f68
Compare
Lee-W
marked this pull request as ready for review
October 13, 2026 09:50
kaxil
approved these changes
Oct 13, 2026
Lee-W
force-pushed
the
validate-connection-type-pydanticai-hook
branch
from
October 13, 2026 18:01
5245f68 to
c8f4542
Compare
A connection of another type, such as openai, made the Pydantic AI operators fail with "BaseHook.__init__() got an unexpected keyword argument 'model_id'", because Connection.get_hook dispatched to a hook from another provider. PydanticAIHook.get_hook now raises a ValueError naming the connection, its actual type and the registered pydanticai types when the type resolves to a hook that is not a PydanticAIHook. Subclass types (Azure, Bedrock, Vertex, Snowflake) pass, even if their module has not been imported yet. A missing or unregistered type is still left to Connection.get_hook.
Generic and email connections are registered with no hook class, so `PydanticAIHook.get_hook` raised an `AttributeError` from `import_string` instead of the new "needs one of [...]" message. They now get the same message as any other non-Pydantic AI connection type. Tighten the `get_hook` tests: add a `generic` rejection case, run `_get_registered_hooks` unpatched once, accept a subclass registered under a type without the `pydanticai` prefix, and assert on the `Connection.get_hook` call instead of `get_connection`.
Lee-W
force-pushed
the
validate-connection-type-pydanticai-hook
branch
from
October 14, 2026 06:58
c8f4542 to
8d0e649
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A connection of another type, such as openai, made the Pydantic AI operators fail with "
BaseHook.__init__()got an unexpected keyword argument 'model_id'", becauseConnection.get_hookdispatched to a hook from another provider.PydanticAIHook.get_hooknow raises aValueErrornaming the connection, its actual type and the registered pydanticai types when the type resolves to a hook that is not aPydanticAIHook. Subclass types (Azure, Bedrock, Vertex, Snowflake) pass, even if their module has not been imported yet. A missing or unregistered type is still left to Connection.get_hook.Was generative AI tooling used to co-author this PR?
Generated-by: [Claude] following the guidelines
{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.