{"record":{"id":"ed9561684eb85765","repo":"karatelabs/karate","slug":"multipart-file-requires-assignment","errorCode":null,"errorMessage":"multipart file requires '=' assignment: ","messagePattern":"multipart file requires '=' assignment: ","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"karate-core/src/main/java/io/karatelabs/core/StepExecutor.java","lineNumber":2420,"sourceCode":"    private void executeStatus(Step step) {\n        int expected = Integer.parseInt(step.getText().trim());\n        Object statusObj = runtime.getVariable(\"responseStatus\");\n        int actual = statusObj instanceof Number n ? n.intValue() : Integer.parseInt(statusObj.toString());\n        if (actual != expected) {\n            throw new AssertionError(\"expected status: \" + expected + \", actual: \" + actual);\n        }\n    }\n\n    /**\n     * Handles: multipart file myFile = { read: 'file.txt', filename: 'test.txt', contentType: 'text/plain' }\n     * Or shorthand: multipart file myFile = read('file.txt')\n     */\n    @SuppressWarnings(\"unchecked\")\n    private void executeMultipartFile(Step step) {\n        String text = step.getText();\n        int eqIndex = StepUtils.findAssignmentOperator(text);\n        if (eqIndex < 0) {\n            throw new RuntimeException(\"multipart file requires '=' assignment: \" + text);\n        }\n        String name = text.substring(0, eqIndex).trim();\n        String expr = text.substring(eqIndex + 1).trim();\n\n        Object value = evalKarateExpression(expr);\n\n        Map<String, Object> multipartMap = new HashMap<>();\n        multipartMap.put(\"name\", name);\n\n        if (value instanceof Map) {\n            Map<String, Object> fileMap = (Map<String, Object>) value;\n            // Handle { read: 'path', filename: 'name', contentType: 'type' }\n            Object readPath = fileMap.get(\"read\");\n            if (readPath != null) {\n                Resource resource = resolveResource(readPath.toString());\n                File file = getFileFromResource(resource);\n                if (file != null) {\n                    multipartMap.put(\"value\", file);","sourceCodeStart":2402,"sourceCodeEnd":2438,"githubUrl":"https://github.com/karatelabs/karate/blob/a22eb90246d958d15a47bf436693d0121ad2812d/karate-core/src/main/java/io/karatelabs/core/StepExecutor.java#L2402-L2438","documentation":"The `multipart file <name> = <expr>` step requires an `=` assignment separating the part name from its value expression. StepExecutor could not find an assignment operator in the step text, so it throws a RuntimeException with the offending text.","triggerScenarios":"Writing `multipart file myFile` (no `= value`), or using syntax the assignment finder doesn't recognize (e.g. missing space or malformed expression).","commonSituations":"Porting V1 scripts with different multipart syntax; typos like `multipart file = myFile` (missing name); copy-paste dropping the value side of the assignment.","solutions":["Write the step as `multipart file myFile = { read: 'file.txt' }` with name, `=`, and value.","Check for typos that removed or misplaced the `=`.","For inline file bytes use `multipart file myFile = read('file.txt')`.","For multiple parts or non-assignment shapes, use `multipart files` with a list/map instead."],"exampleFix":"// before\nAnd multipart file myFile\n// after\nAnd multipart file myFile = { read: 'data/file.txt', filename: 'file.txt', contentType: 'text/plain' }","handlingStrategy":"validation","validationCode":"// Ensure the step text has an '=' assignment before running\n* def stepText = 'multipart file myFile'\n* assert stepText.contains('=') || 'use the correct step syntax'","typeGuard":null,"tryCatchPattern":"try { scenario.run(step) } catch (RuntimeException e) { if (e.getMessage().startsWith(\"multipart file requires '='\")) { /* fix feature syntax */ } throw e; }","preventionTips":["Always write `multipart file <name> = <expression>` with the `=` separator.","Lint feature files for multipart steps missing `=`.","Use an IDE Karate plugin that flags malformed steps.","Prefer `multipart fields`/`multipart files` for complex payloads."],"tags":["karate","multipart","syntax","http"],"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-16T19:17:19.609Z"}