{"record":{"id":"33df2d917e327541","repo":"karatelabs/karate","slug":"configure-logging-expects-a-map-got-value-null-null-value","errorCode":null,"errorMessage":"configure 'logging' expects a map, got: ${value == null ? \"null\" : value.getClass().getName()}","messagePattern":"configure 'logging' expects a map, got: (.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"karate-core/src/main/java/io/karatelabs/core/KarateConfig.java","lineNumber":623,"sourceCode":"            if (map.containsKey(\"logLevel\")) {\n                throw new RuntimeException(\n                        \"'configure report = { logLevel: ... }' is no longer supported; use \"\n                                + \"'configure logging = { report: \\\"info\\\" }' instead \"\n                                + \"(see docs/MIGRATION_GUIDE.md#logging)\");\n            }\n            if (map.containsKey(\"showLog\")) {\n                this.report.put(\"showLog\", toBoolean(map.get(\"showLog\")));\n            }\n            if (map.containsKey(\"showAllSteps\")) {\n                this.report.put(\"showAllSteps\", toBoolean(map.get(\"showAllSteps\")));\n            }\n        }\n    }\n\n    @SuppressWarnings(\"unchecked\")\n    private void configureLogging(Object value) {\n        if (!(value instanceof Map<?, ?> raw)) {\n            throw new RuntimeException(\"configure 'logging' expects a map, got: \"\n                    + (value == null ? \"null\" : value.getClass().getName()));\n        }\n        Map<String, Object> map = (Map<String, Object>) raw;\n        if (map.containsKey(\"report\")) {\n            String levelStr = toString(map.get(\"report\"));\n            this.logging.put(\"report\", levelStr);\n            LogContext.setLogLevel(LogLevel.valueOf(levelStr.toUpperCase()));\n        }\n        if (map.containsKey(\"console\")) {\n            String levelStr = toString(map.get(\"console\"));\n            this.logging.put(\"console\", levelStr);\n            LogContext.setRuntimeLogLevel(levelStr);\n        }\n        if (map.containsKey(\"pretty\")) {\n            boolean pretty = toBoolean(map.get(\"pretty\"));\n            this.logging.put(\"pretty\", pretty);\n            LogContext.get().setPretty(pretty);\n        }","sourceCodeStart":605,"sourceCodeEnd":641,"githubUrl":"https://github.com/karatelabs/karate/blob/a22eb90246d958d15a47bf436693d0121ad2812d/karate-core/src/main/java/io/karatelabs/core/KarateConfig.java#L605-L641","documentation":"The 'configure logging' key must be assigned a Map (e.g. 'configure logging = { report: \"info\", mask: {...} }'). If the assigned value is null or any non-map type (String, number, boolean), configureLogging throws with the actual type name.","triggerScenarios":"Writing 'configure logging = \"info\"' (string instead of map), 'configure logging = true', or 'configure logging = null' in a feature file or karate-config.js.","commonSituations":"Users assuming logging takes a level string directly (the level goes inside the map under 'report'); porting from other frameworks where a simple value is expected; JS code assigning a non-object to logging.","solutions":["Change the value to a map, e.g. 'configure logging = { report: \"info\" }'","If you meant to set the report level, put it under the 'report' key inside the map","Check karate-config.js for variable interpolation that may produce null or a string"],"exampleFix":"// before\n* configure logging = 'info'\n// after\n* configure logging = { report: 'info' }","handlingStrategy":"type-guard","validationCode":"var isLoggingMap = function (v) { return v !== null && typeof v === 'object' && !(v instanceof Array); };","typeGuard":"function isPlainObject(v) { return v != null && v.getClass && java.util.Map.class.isInstance(v); }","tryCatchPattern":"try { karate.configure('logging', v); } catch (RuntimeException e) { if (e.getMessage().contains(\"configure 'logging' expects a map\")) { log.error('logging must be an object/map, got: ' + typeof v); } throw e; }","preventionTips":["Always assign an object literal to configure logging","Put level values under the report key inside the map","Validate generated config objects in karate-config.js before use"],"tags":["configuration","logging","type-mismatch","karate-configuration"],"backgroundTag":"config-type-mismatch","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"}