{"record":{"id":"f08bce0cdb1e579f","repo":"quarkusio/quarkus","slug":"argument-header-cannot-be-null","errorCode":null,"errorMessage":"Argument 'header' cannot be null","messagePattern":"Argument 'header' cannot be null","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/security/CORS.java","lineNumber":124,"sourceCode":"        }\n\n        /**\n         * @param exposedHeaders {@link CORSConfig#exposedHeaders()}\n         * @return this builder\n         */\n        public Builder exposedHeaders(Set<String> exposedHeaders) {\n            this.exposedHeaders = merge(this.exposedHeaders, exposedHeaders, \"Exposed headers\");\n            return this;\n        }\n\n        /**\n         * This method is a shortcut for {@code headers(Set.of(header))}.\n         *\n         * @return this builder\n         */\n        public Builder header(String header) {\n            if (header == null) {\n                throw new IllegalArgumentException(\"Argument 'header' cannot be null\");\n            }\n            return headers(Set.of(header));\n        }\n\n        /**\n         * @param newHeaders {@link CORSConfig#headers()}\n         * @return this builder\n         */\n        public Builder headers(Set<String> newHeaders) {\n            this.headers = merge(this.headers, newHeaders, \"Headers\");\n            return this;\n        }\n\n        /**\n         * This method is a shortcut for {@code methods(Set.of(method))}.\n         *\n         * @return this builder\n         */","sourceCodeStart":106,"sourceCodeEnd":142,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/security/CORS.java#L106-L142","documentation":"Thrown by CORS.Builder.header(String) when a null single header value is passed to the shortcut that delegates to headers(Set.of(header)). Set.of rejects nulls indirectly; the explicit null check names the offending 'header' argument up front. The sibling merge(...) helper performs the equivalent validation for the set-based methods (e.g. exposedHeaders), which report their own argument names.","triggerScenarios":"Calling CORS.builder().header(null), usually from a nullable variable or a lookup that failed.","commonSituations":"Config values or map lookups returning null; conditional code paths where the header name was never initialized.","solutions":["Pass a non-null header name string","Null-check or skip the call when the value is absent","Provide a default header name in config"],"exampleFix":"// before\nbuilder.header(cfg.allowHeader());\n// after\nOptional.ofNullable(cfg.allowHeader()).ifPresent(builder::header);","handlingStrategy":"validation","validationCode":"Objects.requireNonNull(header, \"header must not be null before CORS.builder().header()\");","typeGuard":"boolean isValidHeader(String s) { return s != null && !s.isBlank(); }","tryCatchPattern":null,"preventionTips":["Default config values at load time, not at call time","Avoid passing raw Map.get results into builders","Keep header constants as non-null constants"],"tags":["quarkus","null-argument","cors","illegal-argument"],"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"}