alibaba/nacos · error · NacosApiException

10000

10000

Error message

Request parameter `agentSpecName` should not be blank.

What it means

Thrown by the private AgentValidationUtils.validatePrintableAscii when a character falls outside 0x21-0x7E (i.e. any control char, space 0x20, DEL 0x7F, or non-ASCII). Unlike validateAgentName which allows spaces, this stricter range forbids spaces entirely. The dynamic fieldName and value are interpolated; currently only validateProtocolVersion routes through it with fieldName 'protocolVersion'.

Source

Thrown at ai/src/main/java/com/alibaba/nacos/ai/form/agentspecs/admin/AgentSpecDraftCreateForm.java:44

/**
 * AgentSpec draft create form.
 *
 * @author nacos
 */
public class AgentSpecDraftCreateForm extends AgentSpecForm {
    
    @Serial
    private static final long serialVersionUID = 1L;
    
    private String basedOnVersion;
    
    private String targetVersion;
    
    @Override
    public void validate() throws NacosApiException {
        fillDefaultNamespaceId();
        if (StringUtils.isBlank(getAgentSpecName())) {
            throw new NacosApiException(NacosException.INVALID_PARAM, ErrorCode.PARAMETER_MISSING,
                "Request parameter `agentSpecName` should not be blank.");
        }
    }
    
    public String getBasedOnVersion() {
        return basedOnVersion;
    }
    
    public void setBasedOnVersion(String basedOnVersion) {
        this.basedOnVersion = basedOnVersion;
    }
    
    public String getTargetVersion() {
        return targetVersion;
    }
    
    public void setTargetVersion(String targetVersion) {
        this.targetVersion = targetVersion;

View on GitHub (pinned to 9b989acdf1)

Solutions

  1. Ensure the value contains only printable ASCII 0x21-0x7E (no spaces) for protocolVersion.
  2. Strip whitespace and control characters before submission.
  3. Validate with the same character class the server uses to fail fast locally.

Example fix

// before
filter.setProtocolVersion("1.2.0 rc");
// after
filter.setProtocolVersion("1.2.0-rc");
Defensive patterns

Strategy: validation

Validate before calling

if (value == null) {
    throw new IllegalArgumentException("Invalid " + fieldName + ": null");
}
for (int i = 0; i < value.length(); i++) {
    char c = value.charAt(i);
    if (c < 0x21 || c > 0x7E) {
        throw new IllegalArgumentException("Invalid " + fieldName + ": " + value);
    }
}

Type guard

static boolean isPrintableAsciiNoSpace(String s) {
    return s != null && s.chars().allMatch(c -> c >= 0x21 && c <= 0x7E);
}

Try / catch

try {
    AgentValidationUtils.validateProtocolVersion(protocolVersion);
} catch (IllegalArgumentException e) {
    // return 400, protocolVersion contains non-printable/space
}

Prevention

When it happens

Trigger: Supplying a protocolVersion containing a space, tab, control character, or non-ASCII char (validateProtocolVersion line 150 calls validatePrintableAscii(protocolVersion, "protocolVersion")). Any future caller of validatePrintableAscii would surface its fieldName here.

Common situations: A version string built by concatenation that introduced a space; tab/whitespace from copy-paste; a localized build label with non-ASCII characters.

Related errors


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