{"record":{"id":"19f92ef2f88a65f4","repo":"quarkusio/quarkus","slug":"cookie-value-was-null","errorCode":null,"errorMessage":"Cookie value was null","messagePattern":"Cookie value was null","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"independent-projects/resteasy-reactive/common/runtime/src/main/java/org/jboss/resteasy/reactive/common/util/CookieParser.java","lineNumber":11,"sourceCode":"package org.jboss.resteasy.reactive.common.util;\n\nimport java.util.ArrayList;\nimport java.util.List;\n\nimport jakarta.ws.rs.core.Cookie;\n\npublic class CookieParser {\n    public static List<Cookie> parseCookies(String cookieHeader) {\n        if (cookieHeader == null) {\n            throw new IllegalArgumentException(\"Cookie value was null\");\n        }\n        // cookie headers can be separated by \",\" (HTTP header separator), or \";\" (Cookie separator)\n        // FIXME: the current cookie RFC doesn't mention params for cookies sent by the client\n        // doesn't mention $ as a prefix either\n        // FIXME: make this faster if we have a single cookie\n        try {\n            List<Cookie> cookies = new ArrayList<>();\n\n            int version = 0;\n            String domain = null;\n            String path = null;\n            String cookieName = null;\n            String cookieValue = null;\n\n            String[] parts = cookieHeader.split(\"[;,]\");\n            for (String part : parts) {\n                String[] nv = part.split(\"=\", 2);\n                String name = nv.length > 0 ? nv[0].trim() : \"\";","sourceCodeStart":1,"sourceCodeEnd":29,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/resteasy-reactive/common/runtime/src/main/java/org/jboss/resteasy/reactive/common/util/CookieParser.java#L1-L29","documentation":"CookieParser.parseCookies throws IllegalArgumentException when the Cookie header string passed in is null. It is a strict precondition check: parsing cannot proceed without a header value. Callers are expected to treat a missing Cookie header as 'no cookies' rather than passing null.","triggerScenarios":"Calling CookieParser.parseCookies(null), typically after getHeader(\"Cookie\") returned null on a request with no Cookie header.","commonSituations":"Server-side header parsing where the incoming request has no cookies; utility code that forwards header values without a null check.","solutions":["Null-check the header value before calling parseCookies and return an empty list instead","Use the framework's request.getCookies() (Jakarta REST HttpHeaders) which handles absence gracefully","Wrap the call and convert IllegalArgumentException to an empty result if null is expected in your context"],"exampleFix":"// before\nList<Cookie> cookies = CookieParser.parseCookies(request.getHeader(\"Cookie\"));\n// after\nString header = request.getHeader(\"Cookie\");\nList<Cookie> cookies = header == null ? List.of() : CookieParser.parseCookies(header);","handlingStrategy":"validation","validationCode":"String cookieHeader = request.getHeader(\"Cookie\");\nList<Cookie> cookies = cookieHeader == null ? List.of() : CookieParser.parseCookies(cookieHeader);","typeGuard":"List<Cookie> safeParseCookies(String header) { return header == null ? List.of() : CookieParser.parseCookies(header); }","tryCatchPattern":"List<Cookie> cookies;\ntry {\n    cookies = CookieParser.parseCookies(header);\n} catch (IllegalArgumentException e) {\n    cookies = List.of(); // no Cookie header sent\n}","preventionTips":["Treat a missing Cookie header as an empty list, never pass null","Prefer HttpHeaders.getCookies() over manual parsing when available","Wrap header-parsing utilities with null-safe helpers"],"tags":["resteasy-reactive","cookie","illegal-argument","null-header"],"backgroundTag":"null-argument","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}