{"record":{"id":"9d8e1cc213024623","repo":"karatelabs/karate","slug":"karate-properties-is-read-only-ignoring-write-of-use-system","errorCode":null,"errorMessage":"karate.properties is read-only, ignoring write of '{}' — use System.setProperty() or Runner.Builder.systemProperty() to set one","messagePattern":"karate\\.properties is read-only, ignoring write of '(.+?)' — use System\\.setProperty\\(\\) or Runner\\.Builder\\.systemProperty\\(\\) to set one","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"karate-core/src/main/java/io/karatelabs/core/Suite.java","lineNumber":1290,"sourceCode":"        }\n\n        @Override\n        public boolean containsKey(Object key) {\n            if (overrides != null && overrides.containsKey(key)) {\n                return true;\n            }\n            return key instanceof String name && System.getProperty(name) != null;\n        }\n\n        /**\n         * {@code karate.properties['x'] = 'y'} has never set anything: it used to land in a\n         * throwaway copy and vanish. Kept a no-op rather than made to throw — a script doing it\n         * would start failing — but it is worth one line saying the write went nowhere, since\n         * silently losing it is how someone spends an afternoon.\n         */\n        @Override\n        public String put(String key, String value) {\n            logger.warn(\"karate.properties is read-only, ignoring write of '{}'\"\n                    + \" — use System.setProperty() or Runner.Builder.systemProperty() to set one\", key);\n            return get(key);\n        }\n\n        @Override\n        public Set<Entry<String, String>> entrySet() {\n            Map<String, String> merged = new HashMap<>();\n            System.getProperties().forEach((k, v) -> merged.put(k.toString(), v.toString()));\n            if (overrides != null) {\n                merged.putAll(overrides);\n            }\n            return merged.entrySet();\n        }\n    }\n\n    public DriverProvider getDriverProvider() {\n        return driverProvider;\n    }","sourceCodeStart":1272,"sourceCodeEnd":1308,"githubUrl":"https://github.com/karatelabs/karate/blob/a22eb90246d958d15a47bf436693d0121ad2812d/karate-core/src/main/java/io/karatelabs/core/Suite.java#L1272-L1308","documentation":"In Karate, the karate.properties map exposed to scripts is a read-only view over system properties. Writes via karate.put/putAll are no-ops: the map logs this warning telling the developer the write was ignored and to use System.setProperty() or Runner.Builder.systemProperty() instead. Scripts still read properties normally.","triggerScenarios":"A feature or JS calls karate.properties.put('key','value') (or putAll) at runtime, or a script mutates the properties map returned from karate.properties.","commonSituations":"Porting old scripts that relied on writable karate.properties; tests trying to pass configuration to downstream code by writing a property mid-run; shared utilities that mutate properties instead of using karate.set / variables.","solutions":["Use System.setProperty('key','value') (or in a feature: karate.setSystemProperty) to set a JVM system property","Use Runner.Builder.systemProperty(\"key\",\"value\") to set properties at runner construction time","Use karate.set('name', value) / scenario variables to share values within Karate instead of the properties map","Remove the write entirely if the property was only meant for the same script (a variable suffices)"],"exampleFix":"// before (ignored, warns)\n* karate.properties.put('my.flag', 'true')\n// after\n* karate.setSystemProperty('my.flag', 'true')","handlingStrategy":"type-guard","validationCode":"// detect a read-only properties view before writing\njava.util.Map<String,String> props = karate.getProperties();\ntry { props.put(\"probe\", \"probe\"); props.remove(\"probe\"); System.out.println(\"writable\"); }\ncatch (UnsupportedOperationException e) { System.out.println(\"read-only: use karate.setSystemProperty\"); }","typeGuard":"function propertiesAreWritable(){ try { karate.properties.__probe = 1; delete karate.properties.__probe; return true; } catch(e){ return false; } }","tryCatchPattern":null,"preventionTips":["Treat karate.properties as read-only by convention; never mutate it in shared utilities","Use karate.setSystemProperty(...) inside features to set system properties","Use Runner.Builder.systemProperty(...) for runner-level configuration","Use karate.set(...) / scenario variables for values that only live inside the test"],"tags":["properties","read-only","configuration"],"backgroundTag":"unsupported-operation","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"}