{"record":{"id":"24bbf23987d05659","repo":"alibaba/nacos","slug":"invalid-param-24bbf2","errorCode":"INVALID_PARAM","errorMessage":"Invalid import type: ${request.getImportType()}","messagePattern":"Invalid import type: (.+?)","errorType":"exception","errorClass":"NacosException","httpStatus":400,"severity":"error","filePath":"ai/src/main/java/com/alibaba/nacos/ai/service/McpServerImportService.java","lineNumber":97,"sourceCode":"    \n    /**\n     * Validate servers for import.\n     *\n     * @param namespaceId namespace ID\n     * @param request     import request\n     * @return validation result\n     * @throws NacosException if validation fails\n     * @deprecated use the unified AI resource import validation flow instead. Planned for removal\n     *     in Nacos 3.4.0.\n     */\n    @Deprecated\n    public McpServerImportValidationResult validateImport(String namespaceId,\n        McpServerImportRequest request)\n        throws NacosException {\n        ExternalDataTypeEnum externalDataTypeEnum =\n            ExternalDataTypeEnum.parseType(request.getImportType());\n        if (Objects.isNull(externalDataTypeEnum)) {\n            throw new NacosException(NacosException.INVALID_PARAM,\n                \"Invalid import type: \" + request.getImportType());\n        }\n        \n        try {\n            List<McpServerDetailInfo> servers;\n            servers = transformService.adaptExternalDataToNacosMcpServerFormat(request);\n            return validationService.validateServers(namespaceId, servers);\n            \n        } catch (Exception e) {\n            McpServerImportValidationResult result = new McpServerImportValidationResult();\n            result.setValid(false);\n            List<String> errors = new ArrayList<>();\n            errors.add(\"Import validation failed: \" + e.getMessage());\n            result.setErrors(errors);\n            return result;\n        }\n    }\n    ","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/alibaba/nacos/blob/9b989acdf181d00898f2e8839257bb2b2a3cefe3/ai/src/main/java/com/alibaba/nacos/ai/service/McpServerImportService.java#L79-L115","documentation":"Thrown by the deprecated McpServerImportService.validateImport when request.getImportType() cannot be resolved to an ExternalDataTypeEnum (parseType returns null for blank or unrecognized values). Unlike the adaptor, this path throws a typed NacosException with INVALID_PARAM. Note: a non-null but unsupported type that still maps to an enum would slip past this check.","triggerScenarios":"Calling validateImport(namespaceId, request) where request.getImportType() is null, blank, or a string not equal to 'file'/'json'/'url'.","commonSituations":"Import type not set on the request; case mismatch ('URL' vs 'url'); a custom/legacy type label passed during a migration; frontend defaulting to an empty string.","solutions":["Set importType to an exact lowercase enum name: 'file', 'json', or 'url'.","Validate importType via ExternalDataTypeEnum.parseType before calling validateImport.","Migrate to the unified AI resource import flow; this method is deprecated for removal in 3.4.0."],"exampleFix":"// before\nrequest.setImportType(\"\"); // blank -> null enum -> error\n\n// after\nrequest.setImportType(\"file\");","handlingStrategy":"validation","validationCode":"if (ExternalDataTypeEnum.parseType(request.getImportType()) == null) { throw new NacosException(NacosException.INVALID_PARAM, \"invalid importType\"); }","typeGuard":"boolean knownImportType(String t) { return ExternalDataTypeEnum.parseType(t) != null; }","tryCatchPattern":"try { service.validateImport(ns, request); }\ncatch (NacosException e) { if (e.getErrCode() == NacosException.INVALID_PARAM) fixImportType(); }","preventionTips":["Constrain importType to the enum's exact lowercase names at the API boundary.","Plan migration to the unified AI resource import flow before 3.4.0 removal."],"tags":["mcp","import","validation","deprecated","invalid-param"],"backgroundTag":null,"analyzedSha":"9b989acdf181d00898f2e8839257bb2b2a3cefe3","analyzedAt":"2026-08-14T07:17:31.569Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}