{"record":{"id":"e1293d3469fcd1b3","repo":"alibaba/nacos","slug":"20002-e1293d","errorCode":"20002","errorMessage":"importType must be one of: json, url, file","messagePattern":"importType must be one of: json, url, file","errorType":"validation","errorClass":"NacosApiException","httpStatus":400,"severity":"error","filePath":"ai/src/main/java/com/alibaba/nacos/ai/form/mcp/admin/McpImportForm.java","lineNumber":83,"sourceCode":"    /**\n     * Optional fuzzy search keyword for registry import listing.\n     * Only used when importType is 'url'.\n     */\n    private String search;\n    \n    @Override\n    public void validate() throws NacosApiException {\n        fillDefaultValue();\n        if (StringUtils.isEmpty(importType)) {\n            throw new NacosApiException(NacosException.INVALID_PARAM, ErrorCode.PARAMETER_MISSING,\n                \"Required parameter 'importType' is not present\");\n        }\n        if (StringUtils.isEmpty(data)) {\n            throw new NacosApiException(NacosException.INVALID_PARAM, ErrorCode.PARAMETER_MISSING,\n                \"Required parameter 'data' is not present\");\n        }\n        if (ExternalDataTypeEnum.parseType(importType) == null) {\n            throw new NacosApiException(NacosException.INVALID_PARAM,\n                ErrorCode.PARAMETER_VALIDATE_ERROR,\n                \"importType must be one of: json, url, file\");\n        }\n    }\n    \n    public String getImportType() {\n        return importType;\n    }\n    \n    public void setImportType(String importType) {\n        this.importType = importType;\n    }\n    \n    public String getData() {\n        return data;\n    }\n    \n    public void setData(String data) {","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/alibaba/nacos/blob/9b989acdf181d00898f2e8839257bb2b2a3cefe3/ai/src/main/java/com/alibaba/nacos/ai/form/mcp/admin/McpImportForm.java#L65-L101","documentation":"Thrown by McpImportForm.validate() when importType is non-empty but does not match any ExternalDataTypeEnum (json/url/file). The match is case-SENSITIVE exact (parseType uses equals, not equalsIgnoreCase), unlike the scope checks. Maps to code 20002 (PARAMETER_VALIDATE_ERROR), HTTP 400. Part of the @Deprecated legacy MCP import flow (removal planned 3.4.0).","triggerScenarios":"Calling the MCP import endpoint with importType=JSON, importType=csv, importType=http, or any value other than the lowercase json/url/file.","commonSituations":"Client uppercases the enum; uses 'http' instead of 'url'; passes a free-form string from user input.","solutions":["Set importType to exactly one lowercase value: json, url, or file (case-sensitive).","If accepting user input, validate against the enum before sending.","Migrate to /v3/admin/ai/import."],"exampleFix":"// before (fails — case sensitive)\nimportType=JSON\n// after\nimportType=json","handlingStrategy":"validation","validationCode":"if (!Set.of(\"json\",\"url\",\"file\").contains(importType)) {\n    throw new IllegalArgumentException(\"importType must be json, url, or file (case-sensitive)\");\n}","typeGuard":"static boolean isKnownImportType(String t) {\n    return \"json\".equals(t) || \"url\".equals(t) || \"file\".equals(t);\n}","tryCatchPattern":"catch (NacosApiException e) {\n    if (e.getErrCode() == 20002 && e.getMessage().contains(\"importType\")) { /* use lowercase enum */ }\n}","preventionTips":["Remember importType is case-SENSITIVE (lowercase only).","Map any user-facing choice to the exact enum string."],"tags":["validation","ai","mcp","import","deprecated","parameter","http","api"],"backgroundTag":null,"analyzedSha":"9b989acdf181d00898f2e8839257bb2b2a3cefe3","analyzedAt":"2026-08-14T07:17:31.569Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}