Repository navigation
Open
Description
With #49, Gemini and Vertex tag a rejected credential with ErrorReason.INVALID_CREDENTIALS. The reason travels in details['reason'], so app code can branch on it no matter which plugin raised:
response = await ai.generate(prompt='Suggest a dish.', context={'secrets': {'api_key': tenant_key}})
if response.error and response.error.reason is ErrorReason.INVALID_CREDENTIALS:
... # ask the tenant for a new keyreason is the cross-plugin contract in Python. The other model plugins still set only a status. Each one should pass reason=ErrorReason.INVALID_CREDENTIALS to provider_error(...) when the provider says the key or token it got is bad.
Scope:
- Only credentials the provider rejected. A missing key is a separate decision; leave it as it is.
- Permission errors (403,
AccessDenied) don't get the reason. The credential worked; it just can't do this.
anthropic
- Where:
genkit_anthropic/_models.py:_from_anthropic_error. - Signal: body
error.type == 'authentication_error', which is HTTP 401 andanthropic.AuthenticationError. Today it maps toUNAUTHENTICATEDwith no reason. - Not this:
permission_error(403).
openai (and OpenAI-compatible endpoints built on it)
- Where:
genkit_openai/_models/_utils.py:reraise_openai_error. AnAPIStatusErrorgoes toprovider_error(http_status=...). - Signal:
openai.AuthenticationError(401), or bodyerror.code == 'invalid_api_key'.
amazon-bedrock
- Where (service errors):
genkit_amazon_bedrock/_models.py:_from_client_error, through the_ERROR_CODE_STATUStable. - Signal:
UnrecognizedClientExceptionandExpiredTokenException. - Not this:
AccessDeniedException, which is an IAM or model-access problem. - Where (client-side errors):
_models.py:_from_botocore_error, through_BOTOCORE_ERROR_STATUS. - Signal:
UnauthorizedSSOTokenErrorandTokenRetrievalError.NoCredentialsErrorandPartialCredentialsErrormean the credentials are missing, which is out of scope. _embedders.pyand_image.pyshare these helpers.
vertexai (Model Garden)
- Where:
genkit_vertexai/_model_garden/_client.py:_refresh_credentials. - Signal: a non-transient
RefreshError. ADefaultCredentialsErrormeans the credentials are missing, which is out of scope. - Copy
genkit_google_genai/_auth.py:raise_auth_error.
ollama
- A local server has no auth, so there's nothing to map.
- Behind an auth proxy: the failure shows up as
ollama.ResponseErrorin_models.py,_embedders.pyand_plugin.py, throughprovider_error(http_status=e.status_code). - Signal:
status_code == 401.
Each plugin should get a test that checks the reason both ways: on response.error.reason when generate returns the failure, and on GenkitError.reason when a call raises (embed, model listing).
Metadata
Metadata
Assignees
Labels
No labels
Activity
fix(py): run_main in a running loop, port-exhaustion message, empty r…
fix(py): run_main in a running loop, port-exhaustion message, empty r…
fix(py): run_main in a running loop, port-exhaustion message, empty r…