{"record":{"id":"c1749d155991a065","repo":"alibaba/nacos","slug":"must-be-an-absolute-uri","errorCode":null,"errorMessage":"{} must be an absolute URI","messagePattern":"(.+?) must be an absolute URI","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"ai/src/main/java/com/alibaba/nacos/ai/service/agent/metadata/AgentResourceExtSerializer.java","lineNumber":234,"sourceCode":"            String current = versions.get(i).getVersion();\n            if (AgentVersionComparator.compare(previous, current) <= 0) {\n                throw new IllegalArgumentException(\n                    \"Agent Version catalog must use descending Version order\");\n            }\n        }\n    }\n    \n    private static void validateOptionalAbsoluteUri(String value, String fieldName) {\n        if (value == null) {\n            return;\n        }\n        if (value.isEmpty() || value.codePointCount(0, value.length()) > MAX_URI_LENGTH) {\n            throw new IllegalArgumentException(\"Invalid \" + fieldName);\n        }\n        try {\n            URI uri = new URI(value);\n            if (!uri.isAbsolute()) {\n                throw new IllegalArgumentException(fieldName + \" must be an absolute URI\");\n            }\n        } catch (URISyntaxException e) {\n            throw new IllegalArgumentException(\"Invalid \" + fieldName, e);\n        }\n    }\n    \n    private static void validateOptionalCodePointLength(String value, int maxLength,\n        String fieldName) {\n        if (value != null && value.codePointCount(0, value.length()) > maxLength) {\n            throw new IllegalArgumentException(fieldName + \" exceeds \" + maxLength\n                + \" Unicode code points\");\n        }\n    }\n    \n    private static void validateRequiredCodePointLength(String value, int maxLength,\n        String fieldName) {\n        if (value == null || value.isEmpty()\n            || value.codePointCount(0, value.length()) > maxLength) {","sourceCodeStart":216,"sourceCodeEnd":252,"githubUrl":"https://github.com/alibaba/nacos/blob/9b989acdf181d00898f2e8839257bb2b2a3cefe3/ai/src/main/java/com/alibaba/nacos/ai/service/agent/metadata/AgentResourceExtSerializer.java#L216-L252","documentation":"validateOptionalAbsoluteUri() parses the URI and requires uri.isAbsolute() (a scheme is present). A relative URI such as '/icons/a.png' or 'icons/a.png' parses successfully but is not absolute, so it is rejected with '<fieldName> must be an absolute URI'.","triggerScenarios":"Setting iconUrl or provider.url to a path-only or schemeless reference (no 'http:'/'https:'/'data:' scheme) via the agent create/update API.","commonSituations":"Using a server-relative path intended for a web UI, or a protocol-relative URL ('//cdn/x.png') that java.net.URI treats as non-absolute.","solutions":["Provide a fully-qualified absolute URI including a scheme, e.g. 'https://cdn.example.com/agent.png'.","For inline assets use a data: URI (which is absolute).","Avoid schemeless ('//host/...') and path-relative URIs for iconUrl/provider.url."],"exampleFix":"// before\next.setIconUrl(\"/assets/agent.png\"); // relative -> not absolute\n\n// after\next.setIconUrl(\"https://cdn.example.com/assets/agent.png\");","handlingStrategy":"validation","validationCode":"static boolean isAbsoluteUri(String v) {\n    if (v == null || v.isEmpty()) return true; // optional\n    try { return new java.net.URI(v).isAbsolute(); } catch (java.net.URISyntaxException e) { return false; }\n}\nif (!isAbsoluteUri(ext.getIconUrl())) throw new IllegalArgumentException(\"iconUrl must be absolute\");","typeGuard":"static boolean isAbsoluteUri(String v) {\n    try { return v != null && !v.isEmpty() && new java.net.URI(v).isAbsolute(); }\n    catch (java.net.URISyntaxException e) { return false; }\n}","tryCatchPattern":null,"preventionTips":["Always include a scheme (https:, http:, data:) in iconUrl/provider.url.","Avoid server-relative and protocol-relative URIs for these fields.","Test URI absoluteness on the client with new URI(v).isAbsolute()."],"tags":["ai-registry","agent","uri","validation"],"backgroundTag":null,"analyzedSha":"9b989acdf181d00898f2e8839257bb2b2a3cefe3","analyzedAt":"2026-08-14T07:17:31.569Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}