{"record":{"id":"a63aacf24d87f50a","repo":"karatelabs/karate","slug":"session-is-unavailable-no-sessionstore-is-configured-call-a63aac","errorCode":null,"errorMessage":"session is unavailable: no sessionStore is configured. Call ServerConfig.sessionStore(...) at app startup to enable sessions. Attempted to write session.{name}","messagePattern":"session is unavailable: no sessionStore is configured\\. Call ServerConfig\\.sessionStore\\(\\.\\.\\.\\) at app startup to enable sessions\\. Attempted to write session\\.(.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"karate-core/src/main/java/io/karatelabs/http/ServerMarkupContext.java","lineNumber":155,"sourceCode":"        return vars;\n    }\n\n    /**\n     * Placeholder for the {@code session} binding when no sessionStore\n     * is configured. Throws a clear, actionable error on any access.\n     */\n    private static final class SessionUnavailableProxy implements io.karatelabs.js.ObjectLike {\n\n        static final SessionUnavailableProxy INSTANCE = new SessionUnavailableProxy();\n\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        }","sourceCodeStart":137,"sourceCodeEnd":173,"githubUrl":"https://github.com/karatelabs/karate/blob/a22eb90246d958d15a47bf436693d0121ad2812d/karate-core/src/main/java/io/karatelabs/http/ServerMarkupContext.java#L137-L173","documentation":"Karaté throws this when a template or script accesses `session.<name>` in server-side markup, but no session store was configured on the server. Sessions are opt-in: without a SessionStore there is no backing storage for session variables, so any read or write fails fast with an actionable message. The `write` variant (putMember) is triggered when assigning to a session key.","triggerScenarios":"Evaluating server-side markup that executes `session.myVar = value` (putMember on the SessionBinding) when the HTTP server was built without `ServerConfig.sessionStore(...)`.","commonSituations":"Developers adding session-based state to templates after the server was already configured; copying markup from a project that uses sessions into a new app that never enabled the session store; assuming sessions work by default.","solutions":["Call `ServerConfig.sessionStore(...)` (e.g. with an in-memory or custom SessionStore implementation) at app startup before starting the server.","Remove or guard the `session.<name>` write in the markup if session state is not actually needed.","Use request-scoped or template-local variables instead of the session for state that does not need to persist across requests."],"exampleFix":"// before\nnew HttpServer(config -> config.requestHandler(...)); // no sessionStore\n\n// after\nnew HttpServer(config -> config\n    .sessionStore(new InMemorySessionStore())\n    .requestHandler(...));","handlingStrategy":"validation","validationCode":"// at startup, fail fast if sessions are used but not configured\nif (usesSessions && serverConfig.getSessionStore() == null) {\n    throw new IllegalStateException(\"sessionStore must be configured for session-based markup\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always call ServerConfig.sessionStore(...) in the shared server bootstrap used by all apps.","Add a startup smoke test that renders one session-using template.","Keep session usage centralized so configuration and usage cannot drift apart."],"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"}