{"record":{"id":"c8c148384c7e1066","repo":"chenhg5/cc-connect","slug":"no-active-session-found-key-q","errorCode":null,"errorMessage":"no active session found (key=%q)","messagePattern":"no active session found \\(key=%q\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/engine.go","lineNumber":11281,"sourceCode":"\tplatform   Platform\n\treplyCtx   any\n\tsessionKey string\n}\n\nfunc (e *Engine) SendToSessionInWorkDir(sessionKey, message string, images []ImageAttachment, files []FileAttachment, workDir string, atUsers []string, atAll bool) error {\n\tif message == \"\" && len(images) == 0 && len(files) == 0 {\n\t\treturn fmt.Errorf(\"message or attachment is required\")\n\t}\n\tif (len(images) > 0 || len(files) > 0) && !e.attachmentSendEnabled {\n\t\treturn ErrAttachmentSendDisabled\n\t}\n\n\ttarget, err := e.resolveSendTarget(sessionKey, len(images) > 0 || len(files) > 0)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif target.platform == nil {\n\t\treturn fmt.Errorf(\"no active session found (key=%q)\", sessionKey)\n\t}\n\n\t_, sessions, err := e.getOrCreateWorkspaceAgent(workDir)\n\tif err != nil {\n\t\treturn err\n\t}\n\tsession := sessions.NewSession(target.sessionKey, \"send\")\n\tif message != \"\" {\n\t\tsession.AddHistory(\"assistant\", message)\n\t}\n\tsessions.Save()\n\te.bindSendWorkDir(target.sessionKey, workDir)\n\n\tvar imageSender ImageSender\n\tif len(images) > 0 {\n\t\tvar ok bool\n\t\timageSender, ok = target.platform.(ImageSender)\n\t\tif !ok {","sourceCodeStart":11263,"sourceCodeEnd":11299,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/core/engine.go#L11263-L11299","documentation":"After resolving the send target for the given session key, the engine found the resolved target has a nil platform — meaning no active/interactive session exists for that key. It cannot deliver a message without a live platform connection bound to the session.","triggerScenarios":"Calling SendToSessionInWorkDir (or resolveSendTarget-driven sends) with a sessionKey that no longer matches any entry in e.interactiveStates — the session ended, the bot restarted, or the key was typo'd.","commonSituations":"Scripts caching a session key across bot restarts; sending to a session that the user closed with /new or timeout; racy send issued just after session teardown.","solutions":["Verify the session key is currently active (list sessions) before sending","Re-establish/await the interactive session, then retry with a valid key","Handle the error by re-resolving the key from the current session list instead of caching it"],"exampleFix":"// before\ne.SendToSessionInWorkDir(staleKey, msg, nil, nil, wd, nil, false) // no active session\n// after\nif !sessionExists(e, staleKey) {\n    return fmt.Errorf(\"session %q gone; skipping send\", staleKey)\n}\ne.SendToSessionInWorkDir(staleKey, msg, nil, nil, wd, nil, false)","handlingStrategy":"validation","validationCode":"if engine.ActiveSession(key) == nil {\n    return fmt.Errorf(\"session %q is not active; cannot send\", key)\n}","typeGuard":null,"tryCatchPattern":"if err := e.SendToSessionInWorkDir(key, msg, nil, nil, wd, nil, false); err != nil {\n    if strings.HasPrefix(err.Error(), \"no active session\") {\n        // re-resolve session key from live session list before retrying\n    }\n}","preventionTips":["Do not cache session keys across bot restarts","Re-resolve keys from the live session list at send time","Watch session-lifetime events and invalidate cached keys"],"tags":["go","session","not-found"],"backgroundTag":"resource-not-found","analyzedSha":"4000b2338aa6e850c99df54f8b0ed6ed7460b401","analyzedAt":"2026-09-06T11:45:09.575Z","contentChangedAt":"2026-09-06T11:45:09.575Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}