{"record":{"id":"1a2df1e953c8721a","repo":"alibaba/spring-ai-alibaba","slug":"403","errorCode":"403","errorMessage":"不支持通过接口创建模型配置，请使用 model-config.yml","messagePattern":"不支持通过接口创建模型配置，请使用 model-config\\.yml","errorType":"error_code","errorClass":"StudioException","httpStatus":403,"severity":"error","filePath":"spring-ai-alibaba-admin/spring-ai-alibaba-admin-server-start/src/main/java/com/alibaba/cloud/ai/studio/admin/service/impl/ModelConfigServiceImpl.java","lineNumber":37,"sourceCode":"import org.springframework.util.StringUtils;\n\nimport java.util.List;\nimport java.util.Map;\nimport java.util.stream.Collectors;\n\n@Slf4j\n@Service\n@RequiredArgsConstructor\npublic class ModelConfigServiceImpl implements ModelConfigService {\n\n    private final ModelConfigRepository modelConfigRepository;\n    private final ObjectMapper objectMapper;\n    private final ChatClientFactoryDelegate chatClientFactoryDelegate;\n\n    // 写接口已下线：保留签名以保证接口兼容性（控制器已不再暴露），避免误用\n    @Override\n    public ModelConfigResponse create(ModelConfigCreateRequest request) throws StudioException {\n        throw new StudioException(StudioException.NO_RIGHT, \"不支持通过接口创建模型配置，请使用 model-config.yml\");\n    }\n\n    @Override\n    public ModelConfigResponse update(ModelConfigUpdateRequest request) throws StudioException {\n        throw new StudioException(StudioException.NO_RIGHT, \"不支持通过接口更新模型配置，请使用 model-config.yml\");\n    }\n\n    @Override\n    public void delete(Long id) throws StudioException {\n        throw new StudioException(StudioException.NO_RIGHT, \"不支持通过接口删除模型配置，请使用 model-config.yml\");\n    }\n\n    @Override\n    public PageResult<ModelConfigResponse> list(ModelConfigQueryRequest request) {\n        log.info(\"查询模型配置列表: {}\", request);\n\n        int offset = (request.getPage() - 1) * request.getSize();\n","sourceCodeStart":19,"sourceCodeEnd":55,"githubUrl":"https://github.com/alibaba/spring-ai-alibaba/blob/f82da0b50f35744c13968191be2b1cd2452ef550/spring-ai-alibaba-admin/spring-ai-alibaba-admin-server-start/src/main/java/com/alibaba/cloud/ai/studio/admin/service/impl/ModelConfigServiceImpl.java#L19-L55","documentation":"ModelConfigServiceImpl.create is intentionally disabled: model configurations must be managed via the model-config.yml file. The method always throws StudioException with code NO_RIGHT (403) to preserve API compatibility while preventing misuse.","triggerScenarios":"Any call to the create endpoint/service method, whether the controller was re-exposed, an old client version still calls it, or code invokes the service directly.","commonSituations":"Older frontend or SDK still posting to the removed create endpoint; automation scripts created before the write-interface shutdown; custom integrations that bypass the yml workflow.","solutions":["Add the model configuration to model-config.yml and restart/reload instead of calling the API","Upgrade or update the calling client to stop using the create endpoint","If API writes are genuinely needed, re-enable a controlled write path in a fork — not recommended"],"exampleFix":"// before\nPOST /api/model-configs  {\"name\":\"gpt4\", ...}  // 403\n// after\n# model-config.yml\nmodels:\n  - name: gpt4\n    provider: openai\n    apiKey: ${OPENAI_API_KEY}","handlingStrategy":"try-catch","validationCode":"// No pre-call validation helps: the operation is always rejected; switch to model-config.yml","typeGuard":"null","tryCatchPattern":"try { service.create(req); } catch (StudioException e) { if (e.getCode() == StudioException.NO_RIGHT) { /* use model-config.yml instead */ } }","preventionTips":["Manage all model configs via model-config.yml","Upgrade clients that still call the retired create endpoint","Document the config-file workflow for integrators"],"tags":["forbidden","deprecated","model-config","api-removed"],"backgroundTag":"unsupported-operation","analyzedSha":"f82da0b50f35744c13968191be2b1cd2452ef550","analyzedAt":"2026-09-09T15:32:42.421Z","contentChangedAt":"2026-09-09T15:32:42.421Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}