{"record":{"id":"a544a35f7d7dc145","repo":"alibaba/Sentinel","slug":"parameter-key-cannot-be-empty-a544a3","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-simple-http/src/main/java/com/alibaba/csp/sentinel/transport/heartbeat/client/SimpleHttpRequest.java","lineNumber":92,"sourceCode":"    }\n\n    public SimpleHttpRequest setParams(Map<String, String> params) {\n        this.params = params;\n        return this;\n    }\n\n    public Charset getCharset() {\n        return charset;\n    }\n\n    public SimpleHttpRequest setCharset(Charset charset) {\n        this.charset = charset;\n        return this;\n    }\n\n    public SimpleHttpRequest addParam(String key, String value) {\n        if (StringUtil.isBlank(key)) {\n            throw new IllegalArgumentException(\"Parameter key cannot be empty\");\n        }\n        if (params == null) {\n            params = new HashMap<String, String>();\n        }\n        params.put(key, value);\n        return this;\n    }\n}\n","sourceCodeStart":74,"sourceCodeEnd":101,"githubUrl":"https://github.com/alibaba/Sentinel/blob/a3f40ba8e900c8489bd520274739f17235a7721c/sentinel-transport/sentinel-transport-simple-http/src/main/java/com/alibaba/csp/sentinel/transport/heartbeat/client/SimpleHttpRequest.java#L74-L101","documentation":"SimpleHttpRequest models an outgoing HTTP request for the simple-http transport (used for heartbeats to the dashboard). addParam rejects blank parameter keys (null/empty/whitespace per StringUtil.isBlank) with IllegalArgumentException, because parameters are collected into a Map and serialized into the query string — a blank key would produce a malformed URL.","triggerScenarios":"request.addParam(\"\", value) or addParam(null, value); typically when building heartbeat request parameters from a map whose keys come from dynamic config and one key is absent/empty.","commonSituations":"Custom heartbeat message builders; configuration maps with empty-string keys from property parsing (e.g. trailing comma in a list); tests iterating over maps without filtering.","solutions":["Filter keys before adding: skip entries where StringUtil.isBlank(key)","Fix the source map/config that produced an empty key (often stray delimiters in property lists)","Use fixed, literal parameter names when building SimpleHttpRequest manually"],"exampleFix":"// before\nfor (Map.Entry<String,String> e : params.entrySet()) {\n    request.addParam(e.getKey(), e.getValue());\n}\n\n// after\nfor (Map.Entry<String,String> e : params.entrySet()) {\n    if (StringUtil.isNotBlank(e.getKey())) {\n        request.addParam(e.getKey(), e.getValue());\n    }\n}","handlingStrategy":"validation","validationCode":"for (Map.Entry<String,String> e : params.entrySet()) {\n    if (StringUtil.isNotBlank(e.getKey())) {\n        request.addParam(e.getKey(), e.getValue());\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Filter dynamic key maps for blank entries before building requests","Prefer literal parameter names in custom heartbeat builders"],"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"}