{"record":{"id":"2d4139ff16e4b780","repo":"alibaba/nacos","slug":"unsupported-import-type-externaldatatypeenum","errorCode":null,"errorMessage":"Unsupported import type: ${externalDataTypeEnum}","messagePattern":"Unsupported import type: (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"ai/src/main/java/com/alibaba/nacos/ai/service/McpExternalDataAdaptor.java","lineNumber":123,"sourceCode":"     * Adapt the external data to Nacos MCP server format.\n     *\n     * @param request import request\n     * @return Nacos MCP server format\n     * @throws Exception if adapt failed\n     */\n    public List<McpServerDetailInfo> adaptExternalDataToNacosMcpServerFormat(\n        McpServerImportRequest request) throws Exception {\n        ExternalDataTypeEnum externalDataTypeEnum =\n            ExternalDataTypeEnum.parseType(request.getImportType());\n        if (ExternalDataTypeEnum.FILE.equals(externalDataTypeEnum)) {\n            return adaptOfficialSeedFile(request.getData());\n        } else if (ExternalDataTypeEnum.JSON.equals(externalDataTypeEnum)) {\n            return adaptOfficialMcpServerJsonText(request.getData());\n        } else if (ExternalDataTypeEnum.URL.equals(externalDataTypeEnum)) {\n            return adaptOfficialRegistryUrl(request.getData(), request.getCursor(),\n                request.getLimit(), request.getSearch());\n        } else {\n            throw new IllegalArgumentException(\"Unsupported import type: \" + externalDataTypeEnum);\n        }\n    }\n    \n    /**\n     * Fetch one official MCP registry page and adapt it to Nacos MCP server detail info.\n     *\n     * @param urlData registry endpoint\n     * @param cursor page cursor\n     * @param limit page size\n     * @param search search keyword\n     * @return adapted page result\n     * @throws Exception if registry fetch or adaptation failed\n     */\n    public UrlPageResult fetchOfficialRegistryPage(String urlData, String cursor, Integer limit,\n        String search)\n        throws Exception {\n        if (StringUtils.isBlank(urlData)) {\n            throw new IllegalArgumentException(\"URL is blank\");","sourceCodeStart":105,"sourceCodeEnd":141,"githubUrl":"https://github.com/alibaba/nacos/blob/9b989acdf181d00898f2e8839257bb2b2a3cefe3/ai/src/main/java/com/alibaba/nacos/ai/service/McpExternalDataAdaptor.java#L105-L141","documentation":"Thrown by the deprecated McpExternalDataAdaptor when the import type does not match FILE, JSON, or URL. Because ExternalDataTypeEnum.parseType returns null for unknown/blank values, the final else branch fires with 'Unsupported import type: null' (or the unrecognized value). It is an IllegalArgumentException propagated to the caller.","triggerScenarios":"Calling adaptExternalDataToNacosMcpServerFormat with a McpServerImportRequest whose importType is null, blank, or an unrecognized string (not 'file', 'json', or 'url').","commonSituations":"Passing a custom type label; case mismatch (e.g. 'JSON' vs 'json' since parseType is case-sensitive equals); forgetting to set importType on the request.","solutions":["Set importType to one of the exact lowercase enum names: 'file', 'json', or 'url'.","Validate importType against ExternalDataTypeEnum before calling the adaptor.","Migrate to the unified AI resource import flow, since this adaptor is deprecated for removal in 3.4.0."],"exampleFix":"// before\nrequest.setImportType(\"JSON\"); // case-sensitive -> null enum -> error\n\n// after\nrequest.setImportType(\"json\"); // matches ExternalDataTypeEnum.JSON.getName()","handlingStrategy":"validation","validationCode":"ExternalDataTypeEnum t = ExternalDataTypeEnum.parseType(request.getImportType());\nif (t == null) { throw new IllegalArgumentException(\"unsupported importType: \" + request.getImportType()); }","typeGuard":"boolean isKnownType(String t) {\n    return ExternalDataTypeEnum.parseType(t) != null;\n}","tryCatchPattern":"try { adaptor.adaptExternalDataToNacosMcpServerFormat(request); }\ncatch (IllegalArgumentException e) { handleBadImportType(e); }","preventionTips":["Restrict importType to the enum's lowercase names at the UI/API boundary.","Migrate off the deprecated adaptor to the unified import flow."],"tags":["mcp","import","validation","deprecated","illegal-argument"],"backgroundTag":null,"analyzedSha":"9b989acdf181d00898f2e8839257bb2b2a3cefe3","analyzedAt":"2026-08-14T07:17:31.569Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}