{"record":{"id":"cd1032ab0f6d5163","repo":"alibaba/nacos","slug":"nacos-config-agentnamecodec-must-be-rad-ascii-age","errorCode":null,"errorMessage":"nacos_config agentNameCodec must be {RAD_ASCII_AGENT_NAME_CODEC}","messagePattern":"nacos_config agentNameCodec must be (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"ai/src/main/java/com/alibaba/nacos/ai/service/agent/storage/AgentVersionStorageDescriptorSerializer.java","lineNumber":187,"sourceCode":"            throw new IllegalArgumentException(\"Agent Version mediaType must be \"\n                + AGENT_VERSION_MEDIA_TYPE);\n        }\n        if (!Integer.valueOf(SCHEMA_VERSION).equals(descriptor.getSchemaVersion())) {\n            throw new IllegalArgumentException(\"Agent Version storage schemaVersion must be \"\n                + SCHEMA_VERSION);\n        }\n        Long size = descriptor.getSize();\n        if (size == null || size < 0 || size > MAX_CONTENT_SIZE) {\n            throw new IllegalArgumentException(\n                \"Agent Version storage size must be between 0 and \" + MAX_CONTENT_SIZE);\n        }\n        if (NACOS_CONFIG_PROVIDER.equals(provider)) {\n            if (!NACOS_CONFIG_KEY_FORMAT.equals(descriptor.getKeyFormat())) {\n                throw new IllegalArgumentException(\"nacos_config keyFormat must be \"\n                    + NACOS_CONFIG_KEY_FORMAT);\n            }\n            if (!RAD_ASCII_AGENT_NAME_CODEC.equals(descriptor.getAgentNameCodec())) {\n                throw new IllegalArgumentException(\"nacos_config agentNameCodec must be \"\n                    + RAD_ASCII_AGENT_NAME_CODEC);\n            }\n        }\n    }\n    \n    private static void validateRequiredText(String field, String value, int maxLength) {\n        if (value == null || value.isEmpty() || value.length() > maxLength) {\n            throw new IllegalArgumentException(\"Invalid Agent Version storage \" + field);\n        }\n    }\n    \n    private static void validateOptionalText(String field, String value, int maxLength) {\n        if (value != null) {\n            validateRequiredText(field, value, maxLength);\n        }\n    }\n    \n    private static void validateJsonText(Map<?, ?> root, String field, boolean optional) {","sourceCodeStart":169,"sourceCodeEnd":205,"githubUrl":"https://github.com/alibaba/nacos/blob/9b989acdf181d00898f2e8839257bb2b2a3cefe3/ai/src/main/java/com/alibaba/nacos/ai/service/agent/storage/AgentVersionStorageDescriptorSerializer.java#L169-L205","documentation":"When the provider is 'nacos_config', the agentNameCodec must equal exactly 'rad-ascii-v1' (AgentVersionStorageDescriptor.RAD_AGENT_NAME_CODEC). This pins how agent names are encoded into storage keys for the built-in provider.","triggerScenarios":"validate()/serialize() on a descriptor with provider 'nacos_config' but agentNameCodec null, empty, or any value other than 'rad-ascii-v1'. Fires on a corrupted/custom-edited row too.","commonSituations":"Switching the provider field to nacos_config without setting agentNameCodec; a manual edit; a stale descriptor.","solutions":["Set agentNameCodec to AgentVersionStorageDescriptor.RAD_AGENT_NAME_CODEC when provider is nacos_config","Use AgentVersionStorageService.buildDescriptor, which sets agentNameCodec correctly for the nacos_config provider","Re-publish the version"],"exampleFix":"// before\ndescriptor.setProvider(\"nacos_config\");\ndescriptor.setAgentNameCodec(null);\n// after\ndescriptor.setProvider(\"nacos_config\");\ndescriptor.setAgentNameCodec(AgentVersionStorageDescriptor.RAD_AGENT_NAME_CODEC);","handlingStrategy":"validation","validationCode":"if (AgentVersionStorageDescriptorSerializer.NACOS_CONFIG_PROVIDER.equals(provider)\n        && !AgentVersionStorageDescriptor.RAD_AGENT_NAME_CODEC.equals(descriptor.getAgentNameCodec())) {\n    descriptor.setAgentNameCodec(AgentVersionStorageDescriptor.RAD_AGENT_NAME_CODEC);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use AgentVersionStorageService.buildDescriptor for the nacos_config provider; it sets agentNameCodec correctly","When changing provider, also update the provider-specific fields"],"tags":["java","nacos","ai-agent","validation","provider-contract","storage-descriptor"],"backgroundTag":null,"analyzedSha":"9b989acdf181d00898f2e8839257bb2b2a3cefe3","analyzedAt":"2026-08-14T07:17:31.569Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}