[fix] Resolve Mistral api key issue#3969
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Railway Preview Environment
Updated at 2026-03-13T17:55:09.427Z |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…AI/agenta into fix/mistral-api-key-issue-in-web
There was a problem hiding this comment.
🟡 Custom provider kind matching broken by asymmetric normalization of 'mistralai' alias
In both get_provider_settings and get_provider_settings_from_workflow, request_provider_kind is normalized via _normalize_provider_kind which maps "mistralai" → "mistral" (via _PROVIDER_KIND_ALIASES at sdk/agenta/sdk/managers/secrets.py:16-18). However, for custom providers, secret_provider_kind is still computed with only .lower().replace(" ", "") — which does NOT apply the alias, leaving it as "mistralai". This causes the comparison request_provider_kind == secret_provider_kind ("mistral" != "mistralai") to fail, so credentials are never extracted and the function returns None.
Before this PR, request_provider_kind used re.sub(r"[\s-]+", "", provider.lower()) which did NOT apply any alias, so both sides would be "mistralai" and would match. This is a regression for any custom provider configured with CustomProviderKind.MISTRALAI (a valid enum value in api/oss/src/core/secrets/enums.py:40). The same issue is duplicated in get_provider_settings_from_workflow at lines 371-372.
(Refers to lines 227-228)
Was this helpful? React with 👍 or 👎 to provide feedback.
There was a problem hiding this comment.
🟡 Same asymmetric custom provider kind normalization in get_provider_settings_from_workflow
Duplicate of the same bug as in get_provider_settings: secret_provider_kind for custom providers uses .lower().replace(" ", "") instead of _normalize_provider_kind, so the "mistralai" → "mistral" alias is not applied on the secret side while it IS applied on the request side (sdk/agenta/sdk/managers/secrets.py:349). This causes a mismatch and credentials are never matched for custom providers with kind "mistralai".
(Refers to lines 371-372)
Was this helpful? React with 👍 or 👎 to provide feedback.
Includes
pnpm run format-fix, hence the extra web changes.