{"record":{"id":"217684252e52c07c","repo":"chenhg5/cc-connect","slug":"no-session-found-for-project-q-with-key-q","errorCode":null,"errorMessage":"no session found for project %q with key %q","messagePattern":"no session found for project %q with key %q","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"cmd/cc-connect/session_id.go","lineNumber":140,"sourceCode":"\t\t\t\t\tbest = &candidate{agentID: agentID, updatedAt: updatedAt}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// If the newest match has a valid agent ID, return it.\n\t// If an error match is newer than the best valid match, prefer the error\n\t// (the newest session is still starting and the older ID is stale).\n\tif best != nil {\n\t\tif errCandidate != nil && errCandidate.updatedAt > best.updatedAt {\n\t\t\treturn \"\", definiteErr\n\t\t}\n\t\treturn best.agentID, nil\n\t}\n\tif definiteErr != nil {\n\t\treturn \"\", definiteErr\n\t}\n\treturn \"\", fmt.Errorf(\"no session found for project %q with key %q\", project, sessionKey)\n}\n\n// matchesProject checks if a filename belongs to the given project.\n// Matches: <project>.json, <project>_<hash>.json, <project>_ws_<hash>.json,\n// <project>.sessions.json (legacy).\n//\n// The suffix after <project>_ must look like a hash (hex) or follow the\n// ws_<hash> pattern to avoid false positives with other projects whose\n// name starts with the same prefix (e.g. \"mybot_extra\" vs \"mybot\").\nfunc matchesProject(filename, project string) bool {\n\tif !strings.HasSuffix(filename, \".json\") {\n\t\treturn false\n\t}\n\tbase := strings.TrimSuffix(filename, \".json\")\n\t// Try exact match first (covers <project>.json).\n\tif base == project {\n\t\treturn true\n\t}","sourceCodeStart":122,"sourceCodeEnd":158,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/cmd/cc-connect/session_id.go#L122-L158","documentation":"findAgentSessionID, after scanning all candidate session files, returns the best (newest) definite match; if none matched and there was no definite error, it fails with `no session found for project %q with key %q`. matchesProject supports <project>.json, <project>_<hash>.json, <project>_ws_<hash>.json, and legacy <project>.sessions.json naming, so this means no file/session matching both the project and key was found.","triggerScenarios":"Running `cc-connect agent-sid` with a project name or session key that matches no session file: project path mangled (slashes/hash encoding), wrong key string, or no sessions ever created for that project.","commonSituations":"Typo in --project or --key, running from a machine where the agent never started, project renamed/moved so the encoded hash no longer matches, expecting legacy naming for a session created with the new naming scheme (or vice versa).","solutions":["List the sessions directory (e.g. ~/.claude/projects/) and check the exact filenames for your project","Re-check the --project value — it must match how the agent encodes the workspace path (usually the absolute path)","Start a new agent session to create a session file, then retry agent-sid"],"exampleFix":"// before\ncc-connect agent-sid --project ~/Work/myproj --key abc\n// after\ncc-connect agent-sid --project /home/me/Work/myproj --key abc   # absolute path as encoded by the agent","handlingStrategy":"fallback","validationCode":"ls ~/.claude/projects/ | grep -i myproj   # confirm session files exist before querying","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use the absolute project path exactly as the agent encodes it","Confirm sessions exist before scripting lookups","Handle the not-found case in scripts by starting a new session"],"tags":["cli","sessions","not-found","lookup"],"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"}