alibaba/nacos · error · IllegalArgumentException

nacos_config agentNameCodec must be {RAD_ASCII_AGENT_NAME_CO

Error message

nacos_config agentNameCodec must be {RAD_ASCII_AGENT_NAME_CODEC}

What it means

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.

Source

Thrown at ai/src/main/java/com/alibaba/nacos/ai/service/agent/storage/AgentVersionStorageDescriptorSerializer.java:187

            throw new IllegalArgumentException("Agent Version mediaType must be "
                + AGENT_VERSION_MEDIA_TYPE);
        }
        if (!Integer.valueOf(SCHEMA_VERSION).equals(descriptor.getSchemaVersion())) {
            throw new IllegalArgumentException("Agent Version storage schemaVersion must be "
                + SCHEMA_VERSION);
        }
        Long size = descriptor.getSize();
        if (size == null || size < 0 || size > MAX_CONTENT_SIZE) {
            throw new IllegalArgumentException(
                "Agent Version storage size must be between 0 and " + MAX_CONTENT_SIZE);
        }
        if (NACOS_CONFIG_PROVIDER.equals(provider)) {
            if (!NACOS_CONFIG_KEY_FORMAT.equals(descriptor.getKeyFormat())) {
                throw new IllegalArgumentException("nacos_config keyFormat must be "
                    + NACOS_CONFIG_KEY_FORMAT);
            }
            if (!RAD_ASCII_AGENT_NAME_CODEC.equals(descriptor.getAgentNameCodec())) {
                throw new IllegalArgumentException("nacos_config agentNameCodec must be "
                    + RAD_ASCII_AGENT_NAME_CODEC);
            }
        }
    }
    
    private static void validateRequiredText(String field, String value, int maxLength) {
        if (value == null || value.isEmpty() || value.length() > maxLength) {
            throw new IllegalArgumentException("Invalid Agent Version storage " + field);
        }
    }
    
    private static void validateOptionalText(String field, String value, int maxLength) {
        if (value != null) {
            validateRequiredText(field, value, maxLength);
        }
    }
    
    private static void validateJsonText(Map<?, ?> root, String field, boolean optional) {

View on GitHub (pinned to 9b989acdf1)

Solutions

  1. Set agentNameCodec to AgentVersionStorageDescriptor.RAD_AGENT_NAME_CODEC when provider is nacos_config
  2. Use AgentVersionStorageService.buildDescriptor, which sets agentNameCodec correctly for the nacos_config provider
  3. Re-publish the version

Example fix

// before
descriptor.setProvider("nacos_config");
descriptor.setAgentNameCodec(null);
// after
descriptor.setProvider("nacos_config");
descriptor.setAgentNameCodec(AgentVersionStorageDescriptor.RAD_AGENT_NAME_CODEC);
Defensive patterns

Strategy: validation

Validate before calling

if (AgentVersionStorageDescriptorSerializer.NACOS_CONFIG_PROVIDER.equals(provider)
        && !AgentVersionStorageDescriptor.RAD_AGENT_NAME_CODEC.equals(descriptor.getAgentNameCodec())) {
    descriptor.setAgentNameCodec(AgentVersionStorageDescriptor.RAD_AGENT_NAME_CODEC);
}

Prevention

When it happens

Trigger: 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.

Common situations: Switching the provider field to nacos_config without setting agentNameCodec; a manual edit; a stale descriptor.

Related errors


AI-assisted analysis of alibaba/nacos@9b989acdf1 (2026-08-14). Data as JSON: /api/errors/cd1032ab0f6d5163. Report an issue: GitHub.