alibaba/Sentinel · warning · IllegalArgumentException

Parameter key cannot be empty

Error message

Parameter key cannot be empty

What it means

CommandRequest models an HTTP command request inside Sentinel's transport (command center) layer. addParam rejects a blank key (null, empty, or whitespace-only per StringUtil.isBlank) because parameters live in a Map and a blank key would be ambiguous/irretrievable. This runs on the request-parsing path of both netty-http and simple-http command centers when query/form parameters are added.

Source

Thrown at sentinel-transport/sentinel-transport-common/src/main/java/com/alibaba/csp/sentinel/command/CommandRequest.java:58

        return this;
    }

    public Map<String, String> getParameters() {
        return parameters;
    }

    public String getParam(String key) {
        return parameters.get(key);
    }

    public String getParam(String key, String defaultValue) {
        String value = parameters.get(key);
        return StringUtil.isBlank(value) ? defaultValue : value;
    }

    public CommandRequest addParam(String key, String value) {
        if (StringUtil.isBlank(key)) {
            throw new IllegalArgumentException("Parameter key cannot be empty");
        }
        parameters.put(key, value);
        return this;
    }

    public Map<String, String> getMetadata() {
        return metadata;
    }

    public CommandRequest addMetadata(String key, String value) {
        if (StringUtil.isBlank(key)) {
            throw new IllegalArgumentException("Metadata key cannot be empty");
        }
        metadata.put(key, value);
        return this;
    }
}

View on GitHub (pinned to a3f40ba8e9)

Solutions

  1. Fix the request URL/handler so every parameter has a non-blank name
  2. In custom handlers, guard with if (StringUtil.isNotBlank(key)) before addParam
  3. Sanitize query strings at your ingress (drop empty-name pairs) if you forward external input into the command center

Example fix

// before
request.addParam(paramName, paramValue); // paramName may be ""

// after
if (StringUtil.isNotBlank(paramName)) {
    request.addParam(paramName, paramValue);
}
Defensive patterns

Strategy: validation

Validate before calling

if (StringUtil.isNotBlank(key)) {
    request.addParam(key, value);
}

Try / catch

try { request.addParam(k, v); } catch (IllegalArgumentException e) { /* skip malformed pair */ }

Prevention

When it happens

Trigger: request.addParam("", value) or addParam(null, value); in practice a URL like http://host:8719/commands?=value where a query parameter has an empty name, or custom handler code adding computed parameters where the key expression evaluates to blank.

Common situations: Hand-crafted or proxied URLs with a stray '?' or '&' producing an empty parameter name; writing a custom CommandHandler that builds a CommandRequest from dynamic strings; malformed query strings sent by monitoring scripts.

Related errors


AI-assisted analysis of alibaba/Sentinel@a3f40ba8e9 (2026-08-14). Data as JSON: /api/errors/2071edcd8b004e38. Report an issue: GitHub.