{"record":{"id":"26b560addd0070e1","repo":"alibaba/spring-ai-alibaba","slug":"invalid-params-26b560","errorCode":"INVALID_PARAMS","errorMessage":"modelType is invalid","messagePattern":"modelType is invalid","errorType":"error_code","errorClass":"BizException","httpStatus":null,"severity":"error","filePath":"spring-ai-alibaba-admin/spring-ai-alibaba-admin-server-core/src/main/java/com/alibaba/cloud/ai/studio/core/model/llm/impl/OpenAIProvider.java","lineNumber":93,"sourceCode":"\tpublic List<CredentialSpec> getCredentialSpecs() {\n\t\treturn List.of(\n\t\t\t\tnew CredentialSpec().setCode(\"api_key\")\n\t\t\t\t\t.setDisplayName(\"API Key\")\n\t\t\t\t\t.setDescription(\"API key required to authenticate with the remote model service\")\n\t\t\t\t\t.setPlaceHolder(\"Enter API key\")\n\t\t\t\t\t.setSensitive(true),\n\t\t\t\tnew CredentialSpec().setCode(\"endpoint\")\n\t\t\t\t\t.setDisplayName(\"Endpoint\")\n\t\t\t\t\t.setDescription(\"Endpoint required to call the remote model service\")\n\t\t\t\t\t.setPlaceHolder(\"Enter endpoint\")\n\t\t\t\t\t.setSensitive(false));\n\t}\n\n\t@Override\n\tpublic List<ParameterRule> getParameterRules(String modelId, String modelType) {\n\t\tModelConfigInfo.ModelTypeEnum modelTypeEnum = ModelConfigInfo.ModelTypeEnum.valueOf(modelType);\n\t\tif (modelTypeEnum == null) {\n\t\t\tthrow new BizException(ErrorCode.INVALID_PARAMS.toError(\"modelType\", \"modelType is invalid\"));\n\t\t}\n\t\tswitch (modelTypeEnum) {\n\t\t\tcase llm -> {\n\t\t\t\treturn defaultLLMParameterRules;\n\t\t\t}\n\t\t\tdefault -> {\n\t\t\t\treturn Lists.newArrayList();\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Default parameter rules for LLM models\n\t */\n\tprivate final static List<ParameterRule> defaultLLMParameterRules = Lists.newArrayList(new ParameterRule()\n\t\t.setCode(\"temperature\")\n\t\t.setName(\"temperature\")\n\t\t.setPrecision(2)","sourceCodeStart":75,"sourceCodeEnd":111,"githubUrl":"https://github.com/alibaba/spring-ai-alibaba/blob/f82da0b50f35744c13968191be2b1cd2452ef550/spring-ai-alibaba-admin/spring-ai-alibaba-admin-server-core/src/main/java/com/alibaba/cloud/ai/studio/core/model/llm/impl/OpenAIProvider.java#L75-L111","documentation":"OpenAIProvider.getParameterRules parses the given modelType string with ModelConfigInfo.ModelTypeEnum.valueOf(modelType). The null-check that follows is dead code because valueOf throws IllegalArgumentException on an unknown name; either way the caller gets a failure reported as INVALID_PARAMS \"modelType is invalid\". The provider only supports the \"llm\" case for parameter rules.","triggerScenarios":"Calling getParameterRules(modelId, modelType) with a modelType that is not an exact ModelTypeEnum constant name (e.g. \"LLM\" uppercase, \"chat\", \"embedding\" mismatched case, or an empty string).","commonSituations":"Passing a human-readable model type from a UI dropdown instead of the enum name; case mismatches after an API change (\"LLM\" vs \"llm\"); new model types added elsewhere but not to ModelTypeEnum; passing null modelType.","solutions":["Pass the exact enum constant name defined in ModelConfigInfo.ModelTypeEnum (e.g. \"llm\") as modelType.","Normalize the input before calling: modelType == null ? null : modelType.trim() with consistent casing.","Wrap the call in try/catch (IllegalArgumentException) if the modelType comes from user input, and return a friendly validation message."],"exampleFix":"// before\nprovider.getParameterRules(modelId, \"LLM\");\n// after\nprovider.getParameterRules(modelId, ModelConfigInfo.ModelTypeEnum.llm.name());","handlingStrategy":"validation","validationCode":"// Java\nboolean valid = modelType != null &&\n    Arrays.stream(ModelConfigInfo.ModelTypeEnum.values())\n          .anyMatch(t -> t.name().equals(modelType));","typeGuard":"// Java\nModelConfigInfo.ModelTypeEnum safeType(ModelConfigInfo.ModelTypeEnum[] values, String s) {\n    if (s == null) return null;\n    for (var t : values) {\n        if (t.name().equalsIgnoreCase(s.trim())) return t;\n    }\n    return null;\n}","tryCatchPattern":"try {\n    rules = provider.getParameterRules(modelId, modelType);\n} catch (IllegalArgumentException e) {\n    // unknown modelType — map to llm defaults or reject input\n}","preventionTips":["Pass ModelTypeEnum.name() values, never hand-written strings.","Normalize case/whitespace on modelType coming from UI dropdowns.","Keep ModelTypeEnum and any UI type list in sync."],"tags":["enum","model-type","validation"],"backgroundTag":"invalid-enum-value","analyzedSha":"f82da0b50f35744c13968191be2b1cd2452ef550","analyzedAt":"2026-09-09T15:32:42.421Z","contentChangedAt":"2026-09-09T15:32:42.421Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}