{"record":{"id":"9752a7fa4f84a44f","repo":"alibaba/nacos","slug":"exceeds-unicode-code-points","errorCode":null,"errorMessage":"{} exceeds {} Unicode code points","messagePattern":"(.+?) exceeds (.+?) Unicode code points","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"ai/src/main/java/com/alibaba/nacos/ai/service/agent/metadata/AgentResourceExtSerializer.java","lineNumber":244,"sourceCode":"            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) {\n            throw new IllegalArgumentException(\"Invalid \" + fieldName);\n        }\n    }\n    \n    private static Map<String, Object> toStorageProjection(AgentResourceExt resourceExt) {\n        Map<String, Object> result = new LinkedHashMap<String, Object>();\n        result.put(\"schemaVersion\", AgentResourceExt.SCHEMA_VERSION);\n        putIfPresent(result, \"displayName\", resourceExt.getDisplayName());\n        putIfPresent(result, \"iconUrl\", resourceExt.getIconUrl());\n        if (resourceExt.getProvider() != null) {","sourceCodeStart":226,"sourceCodeEnd":262,"githubUrl":"https://github.com/alibaba/nacos/blob/9b989acdf181d00898f2e8839257bb2b2a3cefe3/ai/src/main/java/com/alibaba/nacos/ai/service/agent/metadata/AgentResourceExtSerializer.java#L226-L262","documentation":"validateOptionalCodePointLength() enforces a Unicode code-point (not char/UTF-16) cap on optional text fields. Currently applied to displayName with MAX_DISPLAY_NAME_LENGTH (128). If the value is non-null and its code-point count exceeds the limit, it throws '<fieldName> exceeds <n> Unicode code points'.","triggerScenarios":"Setting displayName to a string longer than 128 Unicode code points (note: emoji/surrogate pairs count as one code point but two chars) via the agent create/update API.","commonSituations":"Long marketing/display names, names with many emoji (which inflate char count but not code-point count as much), or copy-paste of a paragraph into the display name.","solutions":["Shorten displayName to at most 128 code points.","Compute the limit the same way the validator does: value.codePointCount(0, value.length()) <= 128.","If you need more text, move it into extensions or a description field."],"exampleFix":"// before\next.setDisplayName(veryLongName); // >128 code points\n\n// after\next.setDisplayName(veryLongName.codePointCount(0, veryLongName.length()) <= 128\n    ? veryLongName\n    : veryLongName.substring(0, veryLongName.offsetByCodePoints(0, 128)));","handlingStrategy":"validation","validationCode":"static String clampCodePoints(String v, int max) {\n    if (v == null || v.codePointCount(0, v.length()) <= max) return v;\n    return v.substring(0, v.offsetByCodePoints(0, max));\n}\next.setDisplayName(clampCodePoints(ext.getDisplayName(), 128));","typeGuard":"static boolean withinCodePointLimit(String v, int max) {\n    return v == null || v.codePointCount(0, v.length()) <= max;\n}","tryCatchPattern":null,"preventionTips":["Measure length with codePointCount (not String.length) to match the validator.","Keep displayName concise; move long text to extensions/description.","Trim user input before setting it."],"tags":["ai-registry","agent","text-length","validation"],"backgroundTag":null,"analyzedSha":"9b989acdf181d00898f2e8839257bb2b2a3cefe3","analyzedAt":"2026-08-14T07:17:31.569Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}