{"record":{"id":"2e717ff185ceed17","repo":"charmbracelet/crush","slug":"session-not-found-s-2e717f","errorCode":null,"errorMessage":"session not found: %s","messagePattern":"session not found: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cmd/run.go","lineNumber":677,"sourceCode":"\t\t}\n\t\treturn modelMatch{}, fmt.Errorf(\n\t\t\t\"%s model: model %q found in multiple providers: %s. Please specify provider using 'provider/model' format\",\n\t\t\tlabel, modelID, strings.Join(names, \", \"),\n\t\t)\n\t}\n\treturn matches[0], nil\n}\n\n// resolveSession returns the session to use for a non-interactive run.\n// If continueSessionID is set it fetches that session; if useLast is set it\n// returns the most recently updated top-level session; otherwise it creates a\n// new one.\nfunc resolveSession(ctx context.Context, c *client.Client, wsID, continueSessionID string, useLast bool) (*proto.Session, error) {\n\tswitch {\n\tcase continueSessionID != \"\":\n\t\tsess, err := c.GetSession(ctx, wsID, continueSessionID)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"session not found: %s\", continueSessionID)\n\t\t}\n\t\tif sess.ParentSessionID != \"\" {\n\t\t\treturn nil, fmt.Errorf(\"cannot continue a child session: %s\", continueSessionID)\n\t\t}\n\t\treturn sess, nil\n\n\tcase useLast:\n\t\tsessions, err := c.ListSessions(ctx, wsID)\n\t\tif err != nil || len(sessions) == 0 {\n\t\t\treturn nil, fmt.Errorf(\"no sessions found to continue\")\n\t\t}\n\t\tlast := sessions[0]\n\t\tfor _, s := range sessions[1:] {\n\t\t\tif s.UpdatedAt > last.UpdatedAt && s.ParentSessionID == \"\" {\n\t\t\t\tlast = s\n\t\t\t}\n\t\t}\n\t\treturn &last, nil","sourceCodeStart":659,"sourceCodeEnd":695,"githubUrl":"https://github.com/charmbracelet/crush/blob/7944b8e52225d8805e31eacbf7ef24856b0dfb7a/internal/cmd/run.go#L659-L695","documentation":"resolveSession wraps any error from client.GetSession as \"session not found: %s\" when --continue is given a session ID. It intentionally masks the underlying error (network failure, RPC error, or truly missing session) into a single message, so any failure fetching the session surfaces as 'not found'.","triggerScenarios":"Running `crush run --continue <sessionID>` (or the equivalent API flag) where client.GetSession(ctx, wsID, continueSessionID) returns an error: the session ID does not exist, belongs to a different workspace ID, was deleted, or the server/connection failed.","commonSituations":"Typo or truncated session ID passed to --continue; session created under a different workspace or data-dir (pointing at a fresh DB); session cleaned up by retention; Crush server restarted with an empty data directory.","solutions":["Run `crush session list` (or list sessions via the client) to find a valid, existing session ID and copy it exactly.","Verify you are pointing at the same workspace/data directory (same --data-dir) where the session was created.","Check that the Crush server is running and reachable; a connection error is reported as 'session not found'.","If the session is genuinely gone, drop --continue and start a new session, or use --continue with no ID (useLast)."],"exampleFix":"// before\ncrush run --continue 0a1b2c3d \"fix the bug\"\n// after\ncrush session list            # confirm the real ID\ncrush run --continue 0a1b2c3d-4e5f-... \"fix the bug\"","handlingStrategy":"validation","validationCode":"sessions, _ := c.ListSessions(ctx, wsID)\nvar exists bool\nfor _, s := range sessions {\n    if s.ID == wantID && s.ParentSessionID == \"\" {\n        exists = true\n        break\n    }\n}\nif !exists {\n    return fmt.Errorf(\"skip --continue %s: no such top-level session in this workspace\", wantID)\n}","typeGuard":"func sessionExists(sessions []proto.Session, id string) bool {\n    for _, s := range sessions {\n        if s.ID == id {\n            return true\n        }\n    }\n    return false\n}","tryCatchPattern":"sess, err := resolveSession(ctx, c, wsID, contID, useLast)\nif err != nil {\n    if strings.HasPrefix(err.Error(), \"session not found:\") {\n        log.Warnf(\"session %s unavailable, creating a new one\", contID)\n        sess, err = c.CreateSession(ctx, wsID, \"non-interactive\")\n    }\n    if err != nil {\n        return err\n    }\n}","preventionTips":["Copy session IDs directly from `crush session list`, never by hand.","Always run --continue against the same --data-dir/HOME used to create the session.","Prefer --continue with no ID (last session) in scripts to avoid ID staleness."],"tags":["cli","session","not-found"],"backgroundTag":"session-not-found","analyzedSha":"7944b8e52225d8805e31eacbf7ef24856b0dfb7a","analyzedAt":"2026-08-29T12:48:59.079Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}