alibaba/spring-ai-alibaba · warning
Provider的credential不存在: {}
Error message
Provider的credential不存在: {} What it means
convertToModelConfigDO found the provider via providerManager.getProviderDetail but the ProviderConfigInfo carries no ModelCredential, so no apiKey/endpoint can be attached to the resulting ModelConfigDO; it logs this warning and returns null. The provider exists but is unauthenticated/incomplete.
Source
Thrown at spring-ai-alibaba-admin/spring-ai-alibaba-admin-server-start/src/main/java/com/alibaba/cloud/ai/studio/admin/service/impl/ModelConfigBridgeServiceImpl.java:223
/**
* 将ModelEntity转换为ModelConfigDO
*/
private ModelConfigDO convertToModelConfigDO(ModelEntity modelEntity) {
if (modelEntity == null) {
return null;
}
try {
// 获取Provider的credential(包含apiKey和endpoint)
ProviderConfigInfo providerDetail = providerManager.getProviderDetail(modelEntity.getProvider(), false);
if (providerDetail == null) {
log.warn("Provider不存在: {}", modelEntity.getProvider());
return null;
}
ModelCredential credential = providerDetail.getCredential();
if (credential == null) {
log.warn("Provider的credential不存在: {}", modelEntity.getProvider());
return null;
}
// 解密apiKey
String apiKey = credential.getApiKey();
if (StringUtils.isNotBlank(apiKey)) {
try {
apiKey = RSACryptUtils.decrypt(apiKey);
} catch (Exception e) {
log.warn("解密apiKey失败,使用原始值: {}", e.getMessage());
}
}
// 获取baseUrl,从credential的endpoint获取
String baseUrl = credential.getEndpoint();
if (StringUtils.isNotBlank(baseUrl)) {
// 移除/v1后缀(如果存在),因为Spring AI会自动添加
if (baseUrl.endsWith("/v1") || baseUrl.endsWith("/v1/")) {View on GitHub (pinned to f82da0b50f)
Solutions
- Save an API key credential for the provider in the model management UI so getCredential() returns a ModelCredential
- Verify the credential storage/backend (where ModelCredential records persist) is reachable and populated
- If credential is intentionally optional, change call sites to tolerate the null return instead of failing
- Re-check workspace/tenant scoping — the credential may exist under a different workspace
Example fix
// before
ModelConfigDO config = bridgeService.findById(id);
client.chat(config); // config is null
// after
ModelConfigDO config = bridgeService.findById(id);
if (config == null) { configureProviderCredential(provider); return; } Defensive patterns
Strategy: validation
Validate before calling
if (providerManager.getProviderDetail(provider, false).getCredential() == null) { promptForApiKey(provider); } Try / catch
ModelConfigDO c = bridge.findById(id); if (c == null) { configureCredential(provider); } Prevention
- Enter API keys via the UI on provider setup
- Check credential store population after migrations
- Scope credentials to the correct workspace
When it happens
Trigger: Provider detail exists but getCredential() returns null — i.e., no API key/credential record has ever been saved for that provider.
Common situations: Freshly installed admin where the provider was configured structurally but its API key was never entered; credential was deleted; multi-workspace setup where the credential belongs to another workspace.
Related errors
AI-assisted analysis of alibaba/spring-ai-alibaba@f82da0b50f (2026-09-09).
Data as JSON: /api/errors/b2d415878e29e8ae.
Report an issue: GitHub.