{"record":{"id":"2ae50eeff69fe4b8","repo":"t8y2/dbx","slug":"agent-session-is-quarantined","errorCode":null,"errorMessage":"Agent session is quarantined","messagePattern":"Agent session is quarantined","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"agents/common/src/main/java/com/dbx/agent/MultiSessionJsonRpcServer.java","lineNumber":500,"sourceCode":"        }\n\n        private void expireIdleResources(long nowMillis, long idleTimeoutMillis) {\n            if (state.get() != State.ACTIVE || handler != null) {\n                return;\n            }\n            if (!lock.tryLock()) {\n                return;\n            }\n            try {\n                server.expireIdleResources(nowMillis, idleTimeoutMillis);\n            } finally {\n                lock.unlock();\n            }\n        }\n\n        private void requireActive() {\n            if (state.get() != State.ACTIVE) {\n                throw new IllegalStateException(\"Agent session is quarantined\");\n            }\n        }\n\n        private enum State {\n            ACTIVE,\n            QUARANTINED,\n            CLOSED\n        }\n    }\n}\n","sourceCodeStart":482,"sourceCodeEnd":511,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/common/src/main/java/com/dbx/agent/MultiSessionJsonRpcServer.java#L482-L511","documentation":"Session.requireActive throws IllegalStateException('Agent session is quarantined') when a request or connect is attempted on a session whose state is not ACTIVE. Sessions are quarantined after fatal failures and closed asynchronously, so operations on them are rejected to prevent use of a broken agent.","triggerScenarios":"Calling handleRequest or connect on a session that was quarantined (e.g. after an unrecoverable error or failed connect cleanup) but not yet removed from the sessions map; racing the quarantine/close window.","commonSituations":"Client keeps using a cached session after a previous call failed fatally; cleanup thread has not yet removed the quarantined session; concurrent requests hitting a session mid-quarantine.","solutions":["Treat this error as 'session dead': open a new session and migrate to it","Stop sending requests on the old session ID after any fatal error","Poll/wait for the old session to be removed, then open a fresh one under a new ID","Client-side: map IllegalStateException('quarantined') to your session-reconnect logic"],"exampleFix":"// before\nserver.handleRequest(sessionId, request); // sessionId quarantined\n// after\ntry {\n    server.handleRequest(sessionId, request);\n} catch (IllegalStateException e) {\n    sessionId = server.openSession(connectParams);\n    server.handleRequest(sessionId, request);\n}","handlingStrategy":"try-catch","validationCode":"// track session state client-side; skip calls once a fatal error quarantined the session\nif (markedDead.contains(sessionId)) {\n    sessionId = server.openSession(connectParams);\n}","typeGuard":"boolean usable(Map<String,Object> s) { return \"ACTIVE\".equals(s.get(\"state\")); }","tryCatchPattern":"try {\n    return server.handleRequest(sessionId, request);\n} catch (IllegalStateException e) {\n    if (e.getMessage().contains(\"quarantined\")) {\n        markedDead.add(sessionId);\n        sessionId = server.openSession(connectParams);\n        return server.handleRequest(sessionId, request);\n    }\n    throw e;\n}","preventionTips":["Stop using a session ID after any unrecoverable error response","Recreate the session under a fresh ID rather than retrying a quarantined one","Monitor quarantine/cleanup so clients are notified when sessions die","Serialize requests per session to avoid racing the quarantine window"],"tags":["session-management","quarantine","illegal-state","lifecycle"],"backgroundTag":"session-quarantined","analyzedSha":"c0390bff16418b651f4728520d99adf8ce48829a","analyzedAt":"2026-09-05T23:05:10.900Z","contentChangedAt":"2026-09-05T23:05:10.900Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}