alibaba/spring-ai-alibaba · error · RuntimeException

模型配置解析失败:

Error message

模型配置解析失败: 

What it means

A RuntimeException thrown by ModelConfigParser.checkAndGetModelConfigInfo as a catch-all wrapper: any Exception raised while resolving the model config (JSON parse errors, missing model lookups, unexpected failures) is logged and rethrown as '模型配置解析失败: <cause message>' with the original as the cause. It signals that model config resolution failed for a reason not handled more specifically.

Source

Thrown at spring-ai-alibaba-admin/spring-ai-alibaba-admin-server-start/src/main/java/com/alibaba/cloud/ai/studio/admin/utils/ModelConfigParser.java:102

                    }
                }
                
                // 3. 如果还是找不到,抛出异常
                if (modelEntity == null) {
                    throw new IllegalArgumentException("模型配置不存在: modelId=" + modelConfigInfo.getModelId() + 
                        (modelConfigInfo.getParameter("modelName") != null ? ", modelName=" + modelConfigInfo.getParameter("modelName") : ""));
                }
                
                // 如果从 ModelManager 找到了模型,更新 modelConfigInfo 的 modelId 为 ModelEntity 的 id
                log.info("从 ModelManager 找到模型: id={}, name={}, modelId={}, workspaceId={}", 
                    modelEntity.getId(), modelEntity.getName(), modelEntity.getModelId(), workspaceId);
                
                // 更新 modelId 为 ModelEntity 的 id,确保后续使用正确的 id
                modelConfigInfo.setModelId(modelEntity.getId());
            }
        } catch (Exception e) {
            log.error("解析模型配置失败: modelConfig={}", modelConfig, e);
            throw new RuntimeException("模型配置解析失败: " + e.getMessage(), e);
        }
        return modelConfigInfo;
    }
    
    /**
     * 提取模型调用参数 从ModelConfigInfo中获取动态参数并转换格式
     *
     * @param modelConfigInfo 模型配置信息对象
     * @return 模型调用参数Map
     */
    public Map<String, Object> extractModelParameters(ModelConfigInfo modelConfigInfo) {
        if (modelConfigInfo == null) {
            return new HashMap<>();
        }
        
        Map<String, Object> convertedParameters = new HashMap<>();
        Map<String, Object> originalParameters = modelConfigInfo.getAllParameters();
        

View on GitHub (pinned to f82da0b50f)

Solutions

  1. Read the cause (e.getCause()) / wrapped message to find the underlying failure and fix that specifically.
  2. Fix or re-save the modelConfig JSON so it parses and references an existing model.
  3. Guard the call site: validate config non-empty and the model exists before calling.
  4. Catch RuntimeException around checkAndGetModelConfigInfo and degrade gracefully (e.g. use a default model).

Example fix

// before
ModelConfigInfo info = parser.checkAndGetModelConfigInfo(cfg); // wraps any failure
// after
try {
    ModelConfigInfo info = parser.checkAndGetModelConfigInfo(cfg);
} catch (RuntimeException e) {
    log.error("model config resolve failed", e.getCause());
    throw new BadRequestException("Invalid model config: " + e.getCause().getMessage());
}
Defensive patterns

Strategy: try-catch

Validate before calling

if (cfg == null || cfg.isBlank()) throw new BadRequestException("modelConfig required");

Type guard

null

Try / catch

try { return parser.checkAndGetModelConfigInfo(cfg); } catch (RuntimeException e) { Throwable cause = e.getCause(); log.error("model config failed", cause); throw new BadRequestException(String.valueOf(cause)); }

Prevention

When it happens

Trigger: Calling checkAndGetModelConfigInfo when an inner step throws — e.g. parseModelConfig's IllegalArgumentException for empty/bad JSON, the '模型配置不存在' lookup failure, or any unexpected runtime error during ModelManager resolution.

Common situations: Malformed stored modelConfig; model missing from the registry; transient DB/registry errors during model lookup; changes to ModelConfigInfo schema making old configs unparseable.

Understand the failure class

Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.

Related errors


AI-assisted analysis of alibaba/spring-ai-alibaba@f82da0b50f (2026-09-09). Data as JSON: /api/errors/5611d35debbc72a0. Report an issue: GitHub.