{"record":{"id":"705e30c05b90f469","repo":"alibaba/nacos","slug":"mcp-server-external-id-is-blank-705e30","errorCode":null,"errorMessage":"MCP server external id is blank","messagePattern":"MCP server external id is blank","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"plugin-default-impl/nacos-default-ai-importer-plugin/src/main/java/com/alibaba/nacos/plugin/ai/importer/defaultimpl/mcp/McpRegistryClient.java","lineNumber":99,"sourceCode":"        this(endpoint, new DefaultImportHttpClient(httpClient));\n    }\n    \n    McpRegistryClient(String endpoint, DefaultImportHttpClient httpClient) {\n        if (StringUtils.isBlank(endpoint)) {\n            throw new IllegalArgumentException(\"URL is blank\");\n        }\n        this.endpoint = endpoint.trim();\n        this.httpClient = httpClient;\n    }\n    \n    Page fetchOfficialRegistryPage(String cursor, Integer limit, String search) throws Exception {\n        return fetchUrlPage(endpoint, cursor, limit, search);\n    }\n    \n    McpServerDetailInfo fetchOfficialRegistryServer(String externalId, int limit)\n        throws Exception {\n        if (StringUtils.isBlank(externalId)) {\n            throw new IllegalArgumentException(\"MCP server external id is blank\");\n        }\n        int actualLimit = limit > 0 ? limit : 30;\n        Page page = fetchOfficialRegistryPage(null, actualLimit, externalId);\n        if (CollectionUtils.isNotEmpty(page.getServers())) {\n            for (McpServerDetailInfo each : page.getServers()) {\n                if (StringUtils.equals(externalId, each.getName())\n                    || StringUtils.equals(externalId, each.getId())) {\n                    return each;\n                }\n            }\n        }\n        throw new IllegalStateException(\"MCP server not found in registry: \" + externalId);\n    }\n    \n    private Page fetchUrlPage(String urlData, String cursor, Integer limit, String search)\n        throws Exception {\n        String pageUrl = buildPageUrl(urlData.trim(), cursor, limit, search);\n        ImportHttpResponse response =","sourceCodeStart":81,"sourceCodeEnd":117,"githubUrl":"https://github.com/alibaba/nacos/blob/9b989acdf181d00898f2e8839257bb2b2a3cefe3/plugin-default-impl/nacos-default-ai-importer-plugin/src/main/java/com/alibaba/nacos/plugin/ai/importer/defaultimpl/mcp/McpRegistryClient.java#L81-L117","documentation":"Thrown by McpRegistryClient.fetchOfficialRegistryServer() when the supplied externalId is blank (null, empty, or whitespace-only). The method requires a concrete server identifier to look up an MCP server in the official registry. It is an IllegalArgumentException thrown before any network call.","triggerScenarios":"Calling fetchOfficialRegistryServer(externalId, limit) with externalId that is null, empty, or only spaces; typically reached via the AI registry import API when the caller omits the target server id/name.","commonSituations":"A console/UI import flow that submits an empty selection; a programmatic client that builds the request from an uninitialized field; an upstream parsing bug that yields a blank id.","solutions":["Pass a non-blank externalId — the server name or registry id from a prior search() call.","Validate externalId with StringUtils.isBlank() before invoking the importer and reject early in the UI.","Ensure the import request payload includes the externalId field."],"exampleFix":"// before\nclient.fetchOfficialRegistryServer(\"\", 30);\n\n// after\nif (StringUtils.isBlank(externalId)) {\n    throw new IllegalArgumentException(\"externalId required\");\n}\nclient.fetchOfficialRegistryServer(externalId, 30);","handlingStrategy":"validation","validationCode":"if (com.alibaba.nacos.common.utils.StringUtils.isBlank(externalId)) {\n    throw new IllegalArgumentException(\"MCP server externalId must not be blank\");\n}\nclient.fetchOfficialRegistryServer(externalId, limit);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always resolve an externalId from a prior search before calling fetch.","Reject empty selections in the UI/controller layer before reaching the importer.","Add a null/blank check at the API boundary."],"tags":["ai-registry","mcp","validation","importer"],"backgroundTag":null,"analyzedSha":"9b989acdf181d00898f2e8839257bb2b2a3cefe3","analyzedAt":"2026-08-14T07:17:31.569Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}