{"record":{"id":"3dce5fa6191feda7","repo":"karatelabs/karate","slug":"missing-argument-for-headervalues","errorCode":null,"errorMessage":"missing argument for headerValues()","messagePattern":"missing argument for headerValues\\(\\)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"karate-core/src/main/java/io/karatelabs/http/HttpRequest.java","lineNumber":655,"sourceCode":"                removeHeader(key);\n            }\n\n            @Override\n            public Map<String, Object> toMap() {\n                if (headers == null) {\n                    return Collections.emptyMap();\n                }\n                return new LinkedHashMap<>(headers);\n            }\n        };\n    }\n\n    private JavaInvokable headerValues() {\n        return args -> {\n            if (args.length > 0) {\n                return getHeaderValues(args[0] + \"\");\n            } else {\n                throw new RuntimeException(\"missing argument for headerValues()\");\n            }\n        };\n    }\n\n    private JavaInvokable pathMatches() {\n        return args -> {\n            if (args.length > 0) {\n                return pathMatches(args[0] + \"\");\n            } else {\n                throw new RuntimeException(\"missing argument for pathMatches()\");\n            }\n        };\n    }\n\n    private JavaInvokable multiPart() {\n        return args -> {\n            if (args.length > 0) {\n                return getMultiPart(args[0] + \"\");","sourceCodeStart":637,"sourceCodeEnd":673,"githubUrl":"https://github.com/karatelabs/karate/blob/a22eb90246d958d15a47bf436693d0121ad2812d/karate-core/src/main/java/io/karatelabs/http/HttpRequest.java#L637-L673","documentation":"Generic arity guard inside HttpRequest's private headerValues() invokable: it fires when headerValues() is invoked with zero arguments. The input at fault is the missing header name whose list of values should be returned, so the lookup cannot proceed and this sentinel RuntimeException is thrown.","triggerScenarios":"Calling request.headerValues() with no arguments instead of request.headerValues('Accept').","commonSituations":"Omitted name during edits, empty interpolated variable, expecting a no-arg listing of all headers.","solutions":["Pass the header name: request.headerValues('Set-Cookie')","Ensure the name variable is populated before the call","Use header(name) for the single last-value form when only one value is needed"],"exampleFix":"// before\nvar vs = request.headerValues();\n// after\nvar vs = request.headerValues('Accept');","handlingStrategy":"type-guard","validationCode":"if (name == null || name.isEmpty()) throw new IllegalArgumentException(\"header name required\");","typeGuard":"function requireArg(name, args) { if (args == null || args.length === 0) throw new Error('missing argument for headerValues()'); return name; }","tryCatchPattern":"try { var vs = request.headerValues('Accept'); } catch (RuntimeException e) { /* fix call site: header name missing */ }","preventionTips":["Always pass the header name to headerValues()","Validate interpolated name variables before use","Use header(name) when only the last value is needed"],"tags":["http","headers","arguments","api-misuse"],"backgroundTag":"missing-required-argument","analyzedSha":"a22eb90246d958d15a47bf436693d0121ad2812d","analyzedAt":"2026-09-12T09:01:00.220Z","contentChangedAt":"2026-09-12T09:01:00.220Z","schemaVersion":2},"datasetVersion":"2026-09-16T19:17:19.609Z"}