kaxil commented on code in PR #74451:
URL: https://github.com/apache/airflow/pull/74451#discussion_r4268048823


##########
providers/common/ai/src/airflow/providers/common/ai/hooks/pydantic_ai.py:
##########
@@ -406,13 +406,12 @@ def _resolve_own_model(
             def _provider_factory(pname: str) -> Any:
                 try:
                     return infer_provider_class(pname)(**_kwargs)
-                except TypeError:
-                    self.log.warning(
-                        "Provider '%s' rejected kwargs %s; falling back to 
env-var auth",
-                        pname,
-                        list(_kwargs),
-                    )
-                    return infer_provider(pname)
+                except TypeError as e:
+                    raise ValueError(

Review Comment:
   One caller outside the diff now hits this on a valid connection. 
`_ModelRetryPolicy._hook()` (`policies/retry.py:323-326`, shared by 
`LLMRetryPolicy` and `ClassifierRetryPolicy`) builds a bare `PydanticAIHook` 
instead of `PydanticAIHook.get_hook()` like the operators, so a 
`pydanticai_azure` connection gets the base `{api_key, base_url}` kwargs and 
`AzureProvider` rejects `base_url`. That used to fall back quietly to the 
`AZURE_OPENAI_*` env vars; now every classification raises this `ValueError`, 
`evaluate()` logs "classification failed" and uses `fallback_rules`. Could 
`_hook()` return `PydanticAIHook.get_hook(self.llm_conn_id, 
hook_params={"model_id": self.model_id})`, with a test that an Azure-typed 
connection resolves through `PydanticAIAzureHook`?



##########
providers/common/ai/docs/connections/pydantic_ai_vertex.rst:
##########
@@ -57,8 +57,10 @@ Model
     mean Vertex AI Express Mode credentials (see "Credentials" below), so its
     presence alone cannot tell the two platforms apart. To reach the
     Generative Language API instead, prefix the model explicitly with
-    ``google:`` -- that spelling routes to a different provider regardless of
-    which fields this connection sets.
+    ``google:``. On this connection type that spelling requires ``API Key``

Review Comment:
   The Azure page has the same sentence this one used to have: 
`pydantic_ai_azure.rst` (lines 53-57) says an `openai:` model on an Azure 
connection bypasses Azure entirely, but 
`PydanticAIAzureHook._get_provider_kwargs` always forwards Host as 
`azure_endpoint`, which `OpenAIProvider` doesn't take, so that connection now 
fails `get_conn()`. It probably wants the same wording as here. On this line, 
"requires API Key" and "accepts only an API key" are a little stricter than the 
code, since `GoogleProvider` also takes `base_url` and reads `GOOGLE_API_KEY` 
when no key is set.



##########
providers/common/ai/src/airflow/providers/common/ai/hooks/pydantic_ai.py:
##########
@@ -406,13 +406,12 @@ def _resolve_own_model(
             def _provider_factory(pname: str) -> Any:
                 try:
                     return infer_provider_class(pname)(**_kwargs)
-                except TypeError:
-                    self.log.warning(
-                        "Provider '%s' rejected kwargs %s; falling back to 
env-var auth",
-                        pname,
-                        list(_kwargs),
-                    )
-                    return infer_provider(pname)
+                except TypeError as e:
+                    raise ValueError(
+                        f"Provider '{pname}' rejected the credentials from 
connection "

Review Comment:
   Not every rejected field is a credential. `PydanticAIBedrockHook` always 
forwards `aws_read_timeout` / `aws_connect_timeout` when set, and 
`BedrockMantleProvider` takes neither, so a Bedrock connection with a timeout 
and a `bedrock-mantle:` model is told its credentials were rejected. Something 
like "could not build provider 'X' from the fields on connection 'Y'" would fit 
both cases.



-- 
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