{"record":{"id":"12f3aa5c3efa1466","repo":"karatelabs/karate","slug":"session-is-unavailable-no-sessionstore-is-configured-call-12f3aa","errorCode":null,"errorMessage":"session is unavailable: no sessionStore is configured. Call ServerConfig.sessionStore(...) at app startup to enable sessions. Attempted to read session.(toMap)","messagePattern":"session is unavailable: no sessionStore is configured\\. Call ServerConfig\\.sessionStore\\(\\.\\.\\.\\) at app startup to enable sessions\\. Attempted to read session\\.\\(toMap\\)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"karate-core/src/main/java/io/karatelabs/http/ServerMarkupContext.java","lineNumber":165,"sourceCode":"\n        @Override\n        public Object getMember(String name) {\n            throw sessionUnavailable(name, false);\n        }\n\n        @Override\n        public void putMember(String name, Object value) {\n            throw sessionUnavailable(name, true);\n        }\n\n        @Override\n        public void removeMember(String name) {\n            throw sessionUnavailable(name, true);\n        }\n\n        @Override\n        public Map<String, Object> toMap() {\n            throw sessionUnavailable(\"(toMap)\", false);\n        }\n\n        private static RuntimeException sessionUnavailable(String name, boolean write) {\n            return new RuntimeException(\n                    \"session is unavailable: no sessionStore is configured. \"\n                            + \"Call ServerConfig.sessionStore(...) at app startup to enable sessions. \"\n                            + \"Attempted to \" + (write ? \"write\" : \"read\") + \" session.\" + name);\n        }\n    }\n\n    // MarkupContext implementation\n\n    @Override\n    public String getTemplateName() {\n        return templateName;\n    }\n\n    @Override","sourceCodeStart":147,"sourceCodeEnd":183,"githubUrl":"https://github.com/karatelabs/karate/blob/a22eb90246d958d15a47bf436693d0121ad2812d/karate-core/src/main/java/io/karatelabs/http/ServerMarkupContext.java#L147-L183","documentation":"Reading the whole session (toMap, e.g. via iterating or serializing `session` or `karate.info` style access) requires a session store. With none configured, ServerMarkupContext's session binding refuses even the read path and reports \"Attempted to read session.(toMap)\". The library fails fast rather than returning an empty map, so missing configuration is not silently swallowed.","triggerScenarios":"Markup or JS that reads `session` as a whole (e.g. `session`, `Object.keys(session)`, JSON.stringify of the session binding) on a server without a sessionStore.","commonSituations":"Debug templates that dump the session; logging middleware serializing context; apps migrated from frameworks where sessions silently default to empty maps.","solutions":["Enable sessions via `ServerConfig.sessionStore(...)` at app startup.","Access only specific variables that are not session-backed, or pass needed values through the request/model map instead.","Remove session introspection/debug code from production templates."],"exampleFix":"// before\nconsole.log(JSON.stringify(session));\n\n// after\nconfig -> config.sessionStore(new InMemorySessionStore())...\n// or log a specific non-session model attribute instead","handlingStrategy":"validation","validationCode":"// avoid whole-session reads unless the store is present\nif (!sessionsEnabled) {\n    return {}; // or read specific model attributes instead\n}\nvar snap = session; // safe only when sessionStore configured","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Enable the session store in every environment the templates run in.","Prefer explicit named variables over dumping the whole session.","Remove debug session dumps from production templates."],"tags":["http","session","configuration","server-side"],"backgroundTag":"feature-not-enabled","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"}