alibaba/nacos · error · NacosException
INVALID_PARAM
INVALID_PARAM
Error message
Invalid import type: ${request.getImportType()} What it means
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.
Source
Thrown at ai/src/main/java/com/alibaba/nacos/ai/service/McpServerImportService.java:97
/**
* Validate servers for import.
*
* @param namespaceId namespace ID
* @param request import request
* @return validation result
* @throws NacosException if validation fails
* @deprecated use the unified AI resource import validation flow instead. Planned for removal
* in Nacos 3.4.0.
*/
@Deprecated
public McpServerImportValidationResult validateImport(String namespaceId,
McpServerImportRequest request)
throws NacosException {
ExternalDataTypeEnum externalDataTypeEnum =
ExternalDataTypeEnum.parseType(request.getImportType());
if (Objects.isNull(externalDataTypeEnum)) {
throw new NacosException(NacosException.INVALID_PARAM,
"Invalid import type: " + request.getImportType());
}
try {
List<McpServerDetailInfo> servers;
servers = transformService.adaptExternalDataToNacosMcpServerFormat(request);
return validationService.validateServers(namespaceId, servers);
} catch (Exception e) {
McpServerImportValidationResult result = new McpServerImportValidationResult();
result.setValid(false);
List<String> errors = new ArrayList<>();
errors.add("Import validation failed: " + e.getMessage());
result.setErrors(errors);
return result;
}
}
View on GitHub (pinned to 9b989acdf1)
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.
Example fix
// before
request.setImportType(""); // blank -> null enum -> error
// after
request.setImportType("file"); Defensive patterns
Strategy: validation
Validate before calling
if (ExternalDataTypeEnum.parseType(request.getImportType()) == null) { throw new NacosException(NacosException.INVALID_PARAM, "invalid importType"); } Type guard
boolean knownImportType(String t) { return ExternalDataTypeEnum.parseType(t) != null; } Try / catch
try { service.validateImport(ns, request); }
catch (NacosException e) { if (e.getErrCode() == NacosException.INVALID_PARAM) fixImportType(); } Prevention
- 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.
When it happens
Trigger: Calling validateImport(namespaceId, request) where request.getImportType() is null, blank, or a string not equal to 'file'/'json'/'url'.
Common situations: 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.
Related errors
- 10000
- 20002
- Unsupported import type: ${externalDataTypeEnum}
- URL is blank
- MCP server external id is blank
AI-assisted analysis of alibaba/nacos@9b989acdf1 (2026-08-14).
Data as JSON: /api/errors/24bbf23987d05659.
Report an issue: GitHub.