{"record":{"id":"38e0c7be1b1f21e8","repo":"chenhg5/cc-connect","slug":"multiple-active-sessions-must-specify-session-t","errorCode":null,"errorMessage":"multiple active sessions; must specify --session to send attachments","messagePattern":"multiple active sessions; must specify --session to send attachments","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/engine.go","lineNumber":11375,"sourceCode":"\n\tresolvedSessionKey := sessionKey\n\tvar state *interactiveState\n\tif sessionKey != \"\" {\n\t\tstate = e.interactiveStates[sessionKey]\n\t\tif state == nil && e.multiWorkspace {\n\t\t\tif iKey := e.interactiveKeyForSessionKeyLocked(sessionKey); iKey != sessionKey {\n\t\t\t\tstate = e.interactiveStates[iKey]\n\t\t\t}\n\t\t}\n\t} else if len(e.interactiveStates) == 1 {\n\t\tfor key, s := range e.interactiveStates {\n\t\t\tresolvedSessionKey = key\n\t\t\tstate = s\n\t\t\tbreak\n\t\t}\n\t} else if len(e.interactiveStates) > 1 && attachments {\n\t\te.interactiveMu.Unlock()\n\t\treturn sendTarget{}, fmt.Errorf(\"multiple active sessions; must specify --session to send attachments\")\n\t} else {\n\t\tfor key, s := range e.interactiveStates {\n\t\t\tresolvedSessionKey = key\n\t\t\tstate = s\n\t\t\tbreak\n\t\t}\n\t}\n\te.interactiveMu.Unlock()\n\n\tvar p Platform\n\tvar replyCtx any\n\tif state != nil {\n\t\tstate.mu.Lock()\n\t\tp = state.platform\n\t\treplyCtx = state.replyCtx\n\t\tstate.mu.Unlock()\n\t}\n","sourceCodeStart":11357,"sourceCodeEnd":11393,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/core/engine.go#L11357-L11393","documentation":"When sending attachments, resolveSendTarget needs a single unambiguous session to bind to. If multiple interactive sessions are active and no explicit session key was provided, the engine refuses to guess and asks the caller to specify --session. This prevents attachments being delivered to the wrong conversation.","triggerScenarios":"A send request with attachments and no session identifier while e.interactiveStates holds two or more live sessions.","commonSituations":"CLI/script sends attachments while the user has two chats open with the bot; cron jobs running while several developers each have sessions; after a refactor dropped the --session flag from the invocation.","solutions":["Pass the target session explicitly (--session flag / sessionKey argument)","Reduce to a single active session before sending","Enumerate active session keys and pick the intended one programmatically"],"exampleFix":"// before\ncc-connect send --file report.pdf\n// after\ncc-connect send --session feishu:ou_1234 --file report.pdf","handlingStrategy":"validation","validationCode":"keys := engine.ActiveSessionKeys()\nif len(keys) > 1 && sessionFlag == \"\" {\n    return fmt.Errorf(\"--session required; active: %v\", keys)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass --session in scripts when more than one chat may be active","Enumerate active sessions interactively before attachment sends","Keep one session per automated pipeline"],"tags":["go","cli","ambiguity","session"],"backgroundTag":"missing-required-flag","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"}