{"record":{"id":"5a7bb51060761ee6","repo":"quarkusio/quarkus","slug":"map-key-null","errorCode":null,"errorMessage":"map key null","messagePattern":"map key null","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"independent-projects/resteasy-reactive/common/runtime/src/main/java/org/jboss/resteasy/reactive/common/jaxrs/UriBuilderImpl.java","lineNumber":1096,"sourceCode":"    public String toTemplate() {\n        return buildString(new HashMap<String, Object>(), true, true, true);\n    }\n\n    public UriBuilder resolveTemplate(String name, Object value) throws IllegalArgumentException {\n        if (name == null)\n            throw new IllegalArgumentException(\"Name is null\");\n        if (value == null)\n            throw new IllegalArgumentException(\"Value is null\");\n        HashMap<String, Object> vals = new HashMap<String, Object>();\n        vals.put(name, value);\n        return resolveTemplates(vals);\n    }\n\n    public UriBuilder resolveTemplates(Map<String, Object> templateValues) throws IllegalArgumentException {\n        if (templateValues == null)\n            throw new IllegalArgumentException(\"Template values null\");\n        if (templateValues.containsKey(null))\n            throw new IllegalArgumentException(\"map key null\");\n        return uriTemplate(buildCharSequence(templateValues, false, true, true));\n    }\n\n    public UriBuilder resolveTemplate(String name, Object value, boolean encodeSlashInPath) throws IllegalArgumentException {\n        if (name == null)\n            throw new IllegalArgumentException(\"Name is null\");\n        if (value == null)\n            throw new IllegalArgumentException(\"Value is null\");\n        HashMap<String, Object> vals = new HashMap<String, Object>();\n        vals.put(name, value);\n        return uriTemplate(buildCharSequence(vals, false, true, encodeSlashInPath));\n    }\n\n    public UriBuilder resolveTemplateFromEncoded(String name, Object value) throws IllegalArgumentException {\n        if (name == null)\n            throw new IllegalArgumentException(\"Name is null\");\n        if (value == null)\n            throw new IllegalArgumentException(\"Value is null\");","sourceCodeStart":1078,"sourceCodeEnd":1114,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/resteasy-reactive/common/runtime/src/main/java/org/jboss/resteasy/reactive/common/jaxrs/UriBuilderImpl.java#L1078-L1114","documentation":"UriBuilder.resolveTemplates(Map) throws IllegalArgumentException when the map contains a null key. Template variable names are the map keys, and a null key cannot correspond to any {placeholder} in the template, so it is rejected before resolution.","triggerScenarios":"Passing a HashMap that a caller populated with a null key (HashMap permits null keys), e.g. map.put(null, value) — often from merging maps or reading keyed data where a key is missing.","commonSituations":"Merging several parameter maps where one is keyed by a nullable name; building the map from data where the 'name' column/field is null.","solutions":["Filter out null keys before calling: templateValues.keySet().removeIf(Objects::isNull) on a mutable copy","Fix the producer of the map so keys are always non-null","Validate keys when populating the map and throw a contextual error early"],"exampleFix":"// before\nbuilder.resolveTemplates(params); // params.containsKey(null)\n// after\nMap<String, Object> safe = new HashMap<>(params);\nsafe.keySet().removeIf(Objects::isNull);\nbuilder.resolveTemplates(safe);","handlingStrategy":"validation","validationCode":"for (String key : templateValues.keySet()) {\n    if (key == null) {\n        throw new IllegalArgumentException(\"template value map has a null key\");\n    }\n}\nuriBuilder.resolveTemplates(templateValues);","typeGuard":"boolean hasNoNullKeys(Map<String, Object> m) {\n    return m != null && !m.containsKey(null);\n}","tryCatchPattern":"try {\n    return uriBuilder.resolveTemplates(templateValues);\n} catch (IllegalArgumentException e) {\n    Map<String, Object> cleaned = new HashMap<>(templateValues);\n    cleaned.keySet().removeIf(Objects::isNull);\n    return uriBuilder.resolveTemplates(cleaned);\n}","preventionTips":["Reject null keys when populating parameter maps","Use TreeMap or Map.of() (both reject null keys) for template maps","Sanitize merged maps before passing them on"],"tags":["jax-rs","uri","template","null-check","map"],"backgroundTag":"null-argument-illegal-argument","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}