{"record":{"id":"cc516f91b65d31b9","repo":"alibaba/nacos","slug":"invalid","errorCode":null,"errorMessage":"Invalid {}","messagePattern":"Invalid (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"ai/src/main/java/com/alibaba/nacos/ai/service/agent/metadata/AgentResourceExtSerializer.java","lineNumber":229,"sourceCode":"    private static void validateCatalog(AgentVersionCatalog catalog) {\n        AgentModelValidator.validateVersionCatalog(catalog);\n        List<AgentVersionCatalogEntry> versions = catalog.getOnlineVersions();\n        for (int i = 1; i < versions.size(); i++) {\n            String previous = versions.get(i - 1).getVersion();\n            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    }","sourceCodeStart":211,"sourceCodeEnd":247,"githubUrl":"https://github.com/alibaba/nacos/blob/9b989acdf181d00898f2e8839257bb2b2a3cefe3/ai/src/main/java/com/alibaba/nacos/ai/service/agent/metadata/AgentResourceExtSerializer.java#L211-L247","documentation":"validateOptionalAbsoluteUri() rejects an optional URI field (iconUrl or provider.url) that is non-null but empty, or whose Unicode code-point length exceeds MAX_URI_LENGTH (2048). It throws 'Invalid <fieldName>' before even attempting to parse the URI.","triggerScenarios":"Setting iconUrl or provider.url to \"\" (empty string), or to a very long value (>2048 code points) via the agent create/update API.","commonSituations":"Form handling that submits an empty string instead of omitting the field; pasting a data: URI or a URL with a huge query string.","solutions":["Omit the field (set to null) when you have no URI, rather than passing an empty string.","If the value is legitimately long, shorten it (use a redirect/short link) to stay under 2048 code points.","Validate length with value.codePointCount(0, value.length()) <= 2048 before submitting."],"exampleFix":"// before\next.setIconUrl(\"\"); // empty string triggers 'Invalid iconUrl'\n\n// after\next.setIconUrl(null); // omit when not set","handlingStrategy":"validation","validationCode":"static String normalizeOptionalUri(String v) {\n    if (v == null || v.isEmpty()) return null; // treat empty as absent\n    if (v.codePointCount(0, v.length()) > 2048) throw new IllegalArgumentException(\"uri too long\");\n    return v;\n}\next.setIconUrl(normalizeOptionalUri(ext.getIconUrl()));\next.setProviderUrl(normalizeOptionalUri(provider.getUrl()));","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Omit (set null) optional URI fields instead of passing empty strings.","Keep URIs under 2048 code points; use short links for long values.","Validate length with codePointCount, not length()."],"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"}