{"record":{"id":"f527d5b7946b917b","repo":"alibaba/nacos","slug":"http-code-when-fetching-pageurl-f527d5","errorCode":null,"errorMessage":"HTTP  + code +  when fetching  + pageUrl","messagePattern":"HTTP  \\+ code \\+  when fetching  \\+ pageUrl","errorType":"http","errorClass":"IllegalStateException","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":121,"sourceCode":"        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 =\n            httpClient.get(pageUrl, READ_TIMEOUT_SECONDS, HEADER_ACCEPT_JSON);\n        int code = response.getStatusCode();\n        if (!isSuccessStatus(code)) {\n            throw new IllegalStateException(\"HTTP \" + code + \" when fetching \" + pageUrl);\n        }\n        try {\n            McpRegistryServerList listPage =\n                JacksonUtils.toObj(response.getBody(), McpRegistryServerList.class);\n            List<McpServerDetailInfo> servers = Collections.emptyList();\n            String next = null;\n            if (listPage != null && listPage.getServers() != null) {\n                servers = listPage.getServers().stream()\n                    .map(this::adaptOfficialMcpServerFromResponse)\n                    .collect(Collectors.toList());\n            }\n            if (listPage != null && listPage.getMetadata() != null) {\n                next = listPage.getMetadata().getNextCursor();\n            }\n            return new Page(servers, next);\n        } catch (Exception e) {\n            throw new IllegalStateException(\"Failed to parse response body\", e);\n        }","sourceCodeStart":103,"sourceCodeEnd":139,"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#L103-L139","documentation":"Thrown by McpRegistryClient.fetchUrlPage() as an IllegalStateException when the HTTP GET to the official MCP registry endpoint returns a non-success status code. The message includes the status code and the full URL attempted, aiding diagnosis.","triggerScenarios":"httpClient.get(pageUrl, READ_TIMEOUT_SECONDS, HEADER_ACCEPT_JSON) returns a response whose status code is not in the success range (isSuccessStatus(code) is false); e.g., 404 for a wrong endpoint, 401 for an auth-required registry, 5xx for a registry outage, or a timeout-mapped code.","commonSituations":"Misconfigured registry endpoint URL; registry service temporarily down or rate-limiting (429); network proxy/firewall returning an error page; SSL/TLS handshake failure surfaced as a non-2xx.","solutions":["Verify the configured MCP registry endpoint URL is correct and reachable (curl the URL directly).","Check the registry service health / status page and retry transient 5xx/429 errors.","For persistent 4xx, correct the endpoint configuration; for 5xx, retry with backoff."],"exampleFix":"// before\nnacos.ai.mcp.registry.endpoint=https://registry.example.invalid/api\n\n// after\nnacos.ai.mcp.registry.endpoint=https://registry.example.com/api","handlingStrategy":"retry","validationCode":"// Validate the registry endpoint is reachable before importing.\nImportHttpResponse probe = httpClient.get(endpoint, READ_TIMEOUT_SECONDS, HEADER_ACCEPT_JSON);\nif (!probe.isSuccess()) {\n    throw new IllegalStateException(\"Registry endpoint unhealthy: HTTP \" + probe.getStatusCode());\n}","typeGuard":null,"tryCatchPattern":"int maxRetries = 3;\nfor (int attempt = 1; attempt <= maxRetries; attempt++) {\n    try {\n        return client.fetchOfficialRegistryPage(cursor, limit, search);\n    } catch (IllegalStateException e) {\n        if (!e.getMessage().startsWith(\"HTTP\") || attempt == maxRetries) throw e;\n        // transient 5xx/429 — back off and retry\n    }\n}","preventionTips":["Validate the configured MCP registry endpoint URL before starting an import.","Retry transient 5xx/429 with exponential backoff.","Monitor registry uptime and alert on persistent failures."],"tags":["ai-registry","mcp","network","http","importer"],"backgroundTag":null,"analyzedSha":"9b989acdf181d00898f2e8839257bb2b2a3cefe3","analyzedAt":"2026-08-14T07:17:31.569Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}