{"record":{"id":"1f69ed2b5215f4a3","repo":"karatelabs/karate","slug":"invalid-get-expression-missing","errorCode":null,"errorMessage":"Invalid get expression, missing ]: ","messagePattern":"Invalid get expression, missing \\]: ","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"karate-core/src/main/java/io/karatelabs/core/StepExecutor.java","lineNumber":3153,"sourceCode":"    private Object evalCallOnceExpression(String callExpr) {\n        String tempVar = \"__callOnceResult__\" + System.nanoTime();\n        executeCallOnceWithResult(callExpr, tempVar);\n        return runtime.getVariable(tempVar);\n    }\n\n    /**\n     * Evaluates get[N] varname path or get varname path syntax.\n     * Examples: get[0] foo[*].name, get foo $..bar, get xml //xpath\n     */\n    private Object evalGetExpression(String expr) {\n        int index = -1;\n        String remainder;\n\n        if (expr.startsWith(\"get[\")) {\n            // get[N] syntax\n            int closeBracket = expr.indexOf(']');\n            if (closeBracket < 0) {\n                throw new RuntimeException(\"Invalid get expression, missing ]: \" + expr);\n            }\n            index = Integer.parseInt(expr.substring(4, closeBracket));\n            remainder = expr.substring(closeBracket + 1).trim();\n        } else {\n            // get varname path\n            remainder = expr.substring(4).trim();\n        }\n\n        // Parse varname and path - could be \"varname path\" or \"varname[...]\"\n        String varName;\n        String path;\n\n        // Check if path starts with $ (explicit jsonpath)\n        if (remainder.startsWith(\"$\")) {\n            // get $..path or get[0] $[*].foo - operates on 'response'\n            varName = \"response\";\n            path = remainder;\n        } else {","sourceCodeStart":3135,"sourceCodeEnd":3171,"githubUrl":"https://github.com/karatelabs/karate/blob/a22eb90246d958d15a47bf436693d0121ad2812d/karate-core/src/main/java/io/karatelabs/core/StepExecutor.java#L3135-L3171","documentation":"The `get` keyword supports the `get[N] var.path` syntax for list indexing. The executor scans for the closing ']' to split the index from the remainder path; if the expression starts with 'get[' but contains no ']', the bracket is unbalanced and parsing cannot proceed, so this error is thrown with the raw expression.","triggerScenarios":"`* def x = get[0 foo` (missing closing bracket); nested/broken expressions where the bracket was consumed or mistyped (e.g. `get(0] foo`); truncated text from templating.","commonSituations":"Hand-editing get expressions and dropping the bracket; generating steps programmatically with malformed templates; confusing `get[0] list` with `get list[0]` syntax and mixing forms.","solutions":["Add the closing bracket: `get[0] myList`","Prefer the bracket-on-variable form if clearer: `myList[0]` inside def/eval","Check the step text was not truncated by templating or line-wrapping","Verify no nested brackets are confusing the parser"],"exampleFix":"// before\n* def first = get[0 items\n// after\n* def first = get[0] items","handlingStrategy":"validation","validationCode":"* if (!getExpr.startsWith('get[') || getExpr.indexOf(']') < 0) karate.fail('malformed get expression')","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use the canonical form get[N] var.path with balanced brackets","Prefer var[N] syntax which is harder to malform","Lint step text for unbalanced brackets in generated tests"],"tags":["get","syntax","parsing"],"backgroundTag":"invalid-argument-format","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"}