{"record":{"id":"2071edcd8b004e38","repo":"alibaba/Sentinel","slug":"parameter-key-cannot-be-empty","errorCode":null,"errorMessage":"Parameter key cannot be empty","messagePattern":"Parameter key cannot be empty","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"warning","filePath":"sentinel-transport/sentinel-transport-common/src/main/java/com/alibaba/csp/sentinel/command/CommandRequest.java","lineNumber":58,"sourceCode":"        return this;\n    }\n\n    public Map<String, String> getParameters() {\n        return parameters;\n    }\n\n    public String getParam(String key) {\n        return parameters.get(key);\n    }\n\n    public String getParam(String key, String defaultValue) {\n        String value = parameters.get(key);\n        return StringUtil.isBlank(value) ? defaultValue : value;\n    }\n\n    public CommandRequest addParam(String key, String value) {\n        if (StringUtil.isBlank(key)) {\n            throw new IllegalArgumentException(\"Parameter key cannot be empty\");\n        }\n        parameters.put(key, value);\n        return this;\n    }\n\n    public Map<String, String> getMetadata() {\n        return metadata;\n    }\n\n    public CommandRequest addMetadata(String key, String value) {\n        if (StringUtil.isBlank(key)) {\n            throw new IllegalArgumentException(\"Metadata key cannot be empty\");\n        }\n        metadata.put(key, value);\n        return this;\n    }\n}\n","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/alibaba/Sentinel/blob/a3f40ba8e900c8489bd520274739f17235a7721c/sentinel-transport/sentinel-transport-common/src/main/java/com/alibaba/csp/sentinel/command/CommandRequest.java#L40-L76","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Fix the request URL/handler so every parameter has a non-blank name","In custom handlers, guard with if (StringUtil.isNotBlank(key)) before addParam","Sanitize query strings at your ingress (drop empty-name pairs) if you forward external input into the command center"],"exampleFix":"// before\nrequest.addParam(paramName, paramValue); // paramName may be \"\"\n\n// after\nif (StringUtil.isNotBlank(paramName)) {\n    request.addParam(paramName, paramValue);\n}","handlingStrategy":"validation","validationCode":"if (StringUtil.isNotBlank(key)) {\n    request.addParam(key, value);\n}","typeGuard":null,"tryCatchPattern":"try { request.addParam(k, v); } catch (IllegalArgumentException e) { /* skip malformed pair */ }","preventionTips":["Parse query strings by splitting on '=' and skip pairs with blank names","Never forward raw external input as parameter keys without filtering"],"tags":["sentinel","transport","http","validation"],"backgroundTag":null,"analyzedSha":"a3f40ba8e900c8489bd520274739f17235a7721c","analyzedAt":"2026-08-14T11:10:30.678Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}