alibaba/nacos · error · IllegalArgumentException

Unsupported import type: ${externalDataTypeEnum}

Error message

Unsupported import type: ${externalDataTypeEnum}

What it means

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.

Source

Thrown at ai/src/main/java/com/alibaba/nacos/ai/service/McpExternalDataAdaptor.java:123

     * Adapt the external data to Nacos MCP server format.
     *
     * @param request import request
     * @return Nacos MCP server format
     * @throws Exception if adapt failed
     */
    public List<McpServerDetailInfo> adaptExternalDataToNacosMcpServerFormat(
        McpServerImportRequest request) throws Exception {
        ExternalDataTypeEnum externalDataTypeEnum =
            ExternalDataTypeEnum.parseType(request.getImportType());
        if (ExternalDataTypeEnum.FILE.equals(externalDataTypeEnum)) {
            return adaptOfficialSeedFile(request.getData());
        } else if (ExternalDataTypeEnum.JSON.equals(externalDataTypeEnum)) {
            return adaptOfficialMcpServerJsonText(request.getData());
        } else if (ExternalDataTypeEnum.URL.equals(externalDataTypeEnum)) {
            return adaptOfficialRegistryUrl(request.getData(), request.getCursor(),
                request.getLimit(), request.getSearch());
        } else {
            throw new IllegalArgumentException("Unsupported import type: " + externalDataTypeEnum);
        }
    }
    
    /**
     * Fetch one official MCP registry page and adapt it to Nacos MCP server detail info.
     *
     * @param urlData registry endpoint
     * @param cursor page cursor
     * @param limit page size
     * @param search search keyword
     * @return adapted page result
     * @throws Exception if registry fetch or adaptation failed
     */
    public UrlPageResult fetchOfficialRegistryPage(String urlData, String cursor, Integer limit,
        String search)
        throws Exception {
        if (StringUtils.isBlank(urlData)) {
            throw new IllegalArgumentException("URL is blank");

View on GitHub (pinned to 9b989acdf1)

Solutions

  1. Set importType to one of the exact lowercase enum names: 'file', 'json', or 'url'.
  2. Validate importType against ExternalDataTypeEnum before calling the adaptor.
  3. Migrate to the unified AI resource import flow, since this adaptor is deprecated for removal in 3.4.0.

Example fix

// before
request.setImportType("JSON"); // case-sensitive -> null enum -> error

// after
request.setImportType("json"); // matches ExternalDataTypeEnum.JSON.getName()
Defensive patterns

Strategy: validation

Validate before calling

ExternalDataTypeEnum t = ExternalDataTypeEnum.parseType(request.getImportType());
if (t == null) { throw new IllegalArgumentException("unsupported importType: " + request.getImportType()); }

Type guard

boolean isKnownType(String t) {
    return ExternalDataTypeEnum.parseType(t) != null;
}

Try / catch

try { adaptor.adaptExternalDataToNacosMcpServerFormat(request); }
catch (IllegalArgumentException e) { handleBadImportType(e); }

Prevention

When it happens

Trigger: Calling adaptExternalDataToNacosMcpServerFormat with a McpServerImportRequest whose importType is null, blank, or an unrecognized string (not 'file', 'json', or 'url').

Common situations: 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.

Related errors


AI-assisted analysis of alibaba/nacos@9b989acdf1 (2026-08-14). Data as JSON: /api/errors/2d4139ff16e4b780. Report an issue: GitHub.