{"record":{"id":"fb115389f41bb7b9","repo":"karatelabs/karate","slug":"missing-argument-for-headervalues-httpresponse","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/HttpResponse.java","lineNumber":405,"sourceCode":"        return args -> {\n            if (args.length == 0) {\n                throw new RuntimeException(\"missing argument for header()\");\n            }\n            String name = args[0] + \"\";\n            if (args.length == 1) {\n                return getHeader(name);\n            }\n            putHeaderValue(name, args[1]);\n            return null;\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    /**\n     * Coerce a JS value into the header storage shape ({@code List<String>}).\n     * Shared by {@code header(name, value)} and the {@code headers[name] = v}\n     * bracket-set path.\n     */\n    @SuppressWarnings(\"unchecked\")\n    void putHeaderValue(String name, Object value) {\n        if (value == null) {\n            removeHeader(name);\n            return;\n        }\n        if (value instanceof List<?> list) {\n            List<String> strList = new ArrayList<>(list.size());\n            for (Object o : list) {","sourceCodeStart":387,"sourceCodeEnd":423,"githubUrl":"https://github.com/karatelabs/karate/blob/a22eb90246d958d15a47bf436693d0121ad2812d/karate-core/src/main/java/io/karatelabs/http/HttpResponse.java#L387-L423","documentation":"Generic arity guard inside HttpResponse's private headerValues() invokable (reached via getMember): it fires when headerValues() is invoked on a response with zero arguments. The input at fault is the missing header name; with an argument it returns all values for that response header, and without one this sentinel RuntimeException is thrown.","triggerScenarios":"`response.headerValues()` with zero args, typically when the name variable is undefined or the argument was dropped.","commonSituations":"Multi-value headers like Set-Cookie where a developer explored the API without the name; refactoring that lost the argument.","solutions":["Pass the header name: `response.headerValues('Set-Cookie')`.","Check the name variable is defined/non-null before calling.","For a single value use `response.header(name)` instead.","­"],"exampleFix":"// before\nresponse.headerValues()\n// after\nvar cookies = response.headerValues('Set-Cookie')","handlingStrategy":"validation","validationCode":"if (name != null) var vals = response.headerValues(name);","typeGuard":"function hasHeaderName(v) { return typeof v === 'string' && v.length > 0; }","tryCatchPattern":"try { return response.headerValues(name); } catch (e) { if (('' + e).includes('missing argument')) return []; throw e; }","preventionTips":["Pass a non-empty header name string","Default to response.header(name) when only one value is needed","Verify header names against the actual response headers"],"tags":["http","response","headers"],"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"}