{"record":{"id":"fc143102aba02235","repo":"quarkusio/quarkus","slug":"param-was-null-fc1431","errorCode":null,"errorMessage":"param was null","messagePattern":"param was null","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"independent-projects/resteasy-reactive/common/runtime/src/main/java/org/jboss/resteasy/reactive/common/headers/NewCookieHeaderDelegate.java","lineNumber":25,"sourceCode":"import java.util.Map;\n\nimport jakarta.ws.rs.core.NewCookie;\nimport jakarta.ws.rs.ext.RuntimeDelegate;\n\nimport org.jboss.resteasy.reactive.common.util.DateUtil;\nimport org.jboss.resteasy.reactive.common.util.OrderedParameterParser;\n\n/**\n * @author <a href=\"mailto:bill@burkecentral.com\">Bill Burke</a>\n * @version $Revision: 1 $\n */\npublic class NewCookieHeaderDelegate implements RuntimeDelegate.HeaderDelegate {\n    public static final NewCookieHeaderDelegate INSTANCE = new NewCookieHeaderDelegate();\n    private static final String OLD_COOKIE_PATTERN = \"EEE, dd-MMM-yyyy HH:mm:ss z\";\n\n    public Object fromString(String newCookie) throws IllegalArgumentException {\n        if (newCookie == null)\n            throw new IllegalArgumentException(\"param was null\");\n        String cookieName = null;\n        String cookieValue = null;\n        String comment = null;\n        String domain = null;\n        int maxAge = NewCookie.DEFAULT_MAX_AGE;\n        String path = null;\n        boolean secure = false;\n        int version = NewCookie.DEFAULT_VERSION;\n        boolean httpOnly = false;\n        NewCookie.SameSite sameSite = null;\n        Date expiry = null;\n\n        OrderedParameterParser parser = new OrderedParameterParser();\n        Map<String, String> map = parser.parse(newCookie, ';');\n\n        for (Map.Entry<String, String> entry : map.entrySet()) {\n            String name = entry.getKey();\n            String value = entry.getValue();","sourceCodeStart":7,"sourceCodeEnd":43,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/resteasy-reactive/common/runtime/src/main/java/org/jboss/resteasy/reactive/common/headers/NewCookieHeaderDelegate.java#L7-L43","documentation":"NewCookieHeaderDelegate.fromString parses a Set-Cookie header string into a NewCookie and rejects null input per the JAX-RS HeaderDelegate contract. A null string cannot represent a cookie, so an IllegalArgumentException is thrown before any parsing starts.","triggerScenarios":"Calling NewCookieHeaderDelegate.fromString(null) directly, or feeding a null header value (e.g. missing Set-Cookie from a response map lookup) into RuntimeDelegate cookie conversion.","commonSituations":"Proxying/forwarding cookies where the upstream response had no Set-Cookie header; reading cookies from a Map.get that returned null; optional config values for default cookies.","solutions":["Null-check the cookie string before parsing and treat null as 'no cookie'.","Use a MultiValueMap/headers API that returns an empty list, and branch on isEmpty before conversion.","Catch IllegalArgumentException when the cookie string is genuinely optional."],"exampleFix":"// before\nNewCookie c = (NewCookie) NewCookieHeaderDelegate.INSTANCE.fromString(header);\n// after\nNewCookie c = header == null ? null : (NewCookie) NewCookieHeaderDelegate.INSTANCE.fromString(header);","handlingStrategy":"type-guard","validationCode":"if (cookieHeader == null || cookieHeader.isEmpty()) {\n    return null; // no cookie present\n}","typeGuard":"static boolean hasCookie(String setCookieHeader) {\n    return setCookieHeader != null && !setCookieHeader.isBlank();\n}","tryCatchPattern":"try {\n    return (NewCookie) NewCookieHeaderDelegate.INSTANCE.fromString(raw);\n} catch (IllegalArgumentException e) {\n    return null; // null or unparseable cookie\n}","preventionTips":["Check header maps for presence before converting Set-Cookie values.","Model 'absent cookie' explicitly (Optional/empty list) instead of passing null.","Trim and validate cookie strings obtained from upstream proxies.","Unit-test the no-cookie path of any proxying/forwarding code."],"tags":["http","cookie","null-check","header-parsing"],"backgroundTag":"null-header-value","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}