{"record":{"id":"e9bbf30f3b05fa98","repo":"karatelabs/karate","slug":"pretty-needs-one-argument","errorCode":null,"errorMessage":"pretty() needs one argument","messagePattern":"pretty\\(\\) needs one argument","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"karate-core/src/main/java/io/karatelabs/core/KarateJsUtils.java","lineNumber":392,"sourceCode":"    static JavaInvokable pause() {\n        return args -> {\n            if (args.length == 0 || args[0] == null) {\n                return null;\n            }\n            long millis = ((Number) args[0]).longValue();\n            try {\n                Thread.sleep(millis);\n            } catch (InterruptedException e) {\n                Thread.currentThread().interrupt();\n            }\n            return null;\n        };\n    }\n\n    static JavaInvokable pretty() {\n        return args -> {\n            if (args.length == 0) {\n                throw new RuntimeException(\"pretty() needs one argument\");\n            }\n            Object obj = args[0];\n            if (obj instanceof Map || obj instanceof List) {\n                return StringUtils.formatJson(obj);\n            } else if (obj instanceof Node) {\n                return Xml.toString((Node) obj, true);\n            } else {\n                return obj != null ? obj.toString() : \"null\";\n            }\n        };\n    }\n\n    /**\n     * Generate a range of integers.\n     * Usage: karate.range(0, 5) => [0, 1, 2, 3, 4]\n     *        karate.range(0, 10, 2) => [0, 2, 4, 6, 8]\n     *        karate.range(5, 0, -1) => [5, 4, 3, 2, 1]\n     */","sourceCodeStart":374,"sourceCodeEnd":410,"githubUrl":"https://github.com/karatelabs/karate/blob/a22eb90246d958d15a47bf436693d0121ad2812d/karate-core/src/main/java/io/karatelabs/core/KarateJsUtils.java#L374-L410","documentation":"pretty() is a Karate JS utility that pretty-prints a value: Maps/Lists via JSON formatting, XML Nodes via Xml.toString. It throws this error when called with zero arguments, since there is no value to format.","triggerScenarios":"karate.pretty() with no arguments, e.g. pretty() instead of pretty(response).","commonSituations":"Debug-printing in a Scenario and forgetting to pass the variable; the variable name was deleted during cleanup; copying karate.pretty from docs without adapting the argument.","solutions":["Pass the value to print: pretty(myMap), pretty(response), or pretty(xmlNode).","If the value may be undefined, print a fallback string instead: pretty(variable || '(missing)').","For plain XML strings prefer prettyXml(), which also accepts strings."],"exampleFix":"// before\nprint pretty()\n// after\nprint pretty(response)","handlingStrategy":"type-guard","validationCode":"if (response) { print pretty(response) } else { print '(no response)' }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["pretty() takes exactly one argument — the value to format.","Use pretty() for JSON-shaped data and prettyXml() for XML.","Bind the value to a named variable first, then print pretty(thatVariable)."],"tags":["karate","javascript","argument-count","debugging"],"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"}