{"record":{"id":"3bb089d9c367c467","repo":"karatelabs/karate","slug":"missing-argument-for-pathmatches","errorCode":null,"errorMessage":"missing argument for pathMatches()","messagePattern":"missing argument for pathMatches\\(\\)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"karate-core/src/main/java/io/karatelabs/http/HttpRequest.java","lineNumber":665,"sourceCode":"        };\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] + \"\");\n            } else {\n                throw new RuntimeException(\"missing argument for multiPart()\");\n            }\n        };\n    }\n\n    private JavaInvokable file() {\n        return args -> {\n            if (args.length > 0) {\n                return getFile(args[0] + \"\");","sourceCodeStart":647,"sourceCodeEnd":683,"githubUrl":"https://github.com/karatelabs/karate/blob/a22eb90246d958d15a47bf436693d0121ad2812d/karate-core/src/main/java/io/karatelabs/http/HttpRequest.java#L647-L683","documentation":"The request.pathMatches() invokable requires one argument (a URI-template pattern) to test against the request path. With zero arguments it throws RuntimeException 'missing argument for pathMatches()'.","triggerScenarios":"Calling request.pathMatches() with no arguments instead of request.pathMatches('/users/{id}').","commonSituations":"Dropped pattern argument in mock/route scripts, empty variable interpolated as the pattern, confusion with a no-arg path getter.","solutions":["Pass the path pattern: request.pathMatches('/api/{version}/items')","Verify the pattern variable is non-empty before the call","Use the plain path accessor if you only need the path without matching"],"exampleFix":"// before\nvar m = request.pathMatches();\n// after\nvar m = request.pathMatches('/users/{id}');","handlingStrategy":"type-guard","validationCode":"if (pattern == null || pattern.isEmpty()) throw new IllegalArgumentException(\"path pattern required\");","typeGuard":"function requireArg(pattern, args) { if (args == null || args.length === 0) throw new Error('missing argument for pathMatches()'); return pattern; }","tryCatchPattern":"try { var m = request.pathMatches('/users/{id}'); } catch (RuntimeException e) { /* fix call site: pattern missing */ }","preventionTips":["Always pass the URI-template pattern to pathMatches()","Validate pattern variables are non-empty before interpolation","Keep patterns in named constants to avoid accidental omission in route scripts"],"tags":["http","routing","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-19T12:17:13.211Z"}