{"record":{"id":"6d4530886be2390f","repo":"charmbracelet/crush","slug":"session-not-found-s","errorCode":null,"errorMessage":"session not found: %s","messagePattern":"session not found: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/app/app.go","lineNumber":246,"sourceCode":"// is nil-safe. Call this whenever the active session changes (load,\n// new, or select).\nfunc (app *App) ReportCurrentSession(sessionID string) {\n\tapp.herdrClient.SetSessionID(sessionID)\n}\n\n// resolveSession resolves which session to use for a non-interactive run\n// If continueSessionID is set, it looks up that session by ID\n// If useLast is set, it returns the most recently updated top-level session\n// Otherwise, it creates a new session\nfunc (app *App) resolveSession(ctx context.Context, continueSessionID string, useLast bool) (session.Session, error) {\n\tswitch {\n\tcase continueSessionID != \"\":\n\t\tif app.Sessions.IsAgentToolSession(continueSessionID) {\n\t\t\treturn session.Session{}, fmt.Errorf(\"cannot continue an agent tool session: %s\", continueSessionID)\n\t\t}\n\t\tsess, err := app.Sessions.Get(ctx, continueSessionID)\n\t\tif err != nil {\n\t\t\treturn session.Session{}, fmt.Errorf(\"session not found: %s\", continueSessionID)\n\t\t}\n\t\tif sess.ParentSessionID != \"\" {\n\t\t\treturn session.Session{}, fmt.Errorf(\"cannot continue a child session: %s\", continueSessionID)\n\t\t}\n\t\treturn sess, nil\n\n\tcase useLast:\n\t\tsess, err := app.Sessions.GetLast(ctx)\n\t\tif err != nil {\n\t\t\treturn session.Session{}, fmt.Errorf(\"no sessions found to continue\")\n\t\t}\n\t\treturn sess, nil\n\n\tdefault:\n\t\treturn app.Sessions.Create(ctx, agent.DefaultSessionName)\n\t}\n}\n","sourceCodeStart":228,"sourceCodeEnd":264,"githubUrl":"https://github.com/charmbracelet/crush/blob/7944b8e52225d8805e31eacbf7ef24856b0dfb7a/internal/app/app.go#L228-L264","documentation":"resolveSession looked up the given session ID via app.Sessions.Get and the record does not exist (or the DB lookup failed). The tool cannot continue a conversation with an unknown session ID.","triggerScenarios":"Passing a --continue/--session ID that was never created, was deleted, was created in a different project/data directory (different SQLite file), or contains a typo.","commonSituations":"Reusing session IDs across different working directories or after wiping ~/.local/share/crush; stale IDs in shell scripts; truncated/copied-partial IDs from logs.","solutions":["List existing sessions and copy the exact ID (crush sessions or equivalent command).","Confirm you are in the same project directory — sessions are stored per data directory.","Omit the session flag to create a new session instead of continuing.","Check the ID for typos/truncation (UUID must match exactly)."],"exampleFix":"// before\ncrush run --continue 9f8e7d2c-1111-2222-3333-444455556666 \"fix the bug\"\n\n// after\ncrush sessions            # verify the ID exists in this project\ncrush run --continue <verified-id> \"fix the bug\"","handlingStrategy":"validation","validationCode":"if _, err := app.Sessions.Get(ctx, sessionID); err != nil {\n    return fmt.Errorf(\"session %s does not exist in this project's data dir\", sessionID)\n}","typeGuard":null,"tryCatchPattern":"if err != nil {\n    if strings.HasPrefix(err.Error(), \"session not found\") {\n        sess, cerr := app.Sessions.Create(ctx, agent.DefaultSessionName) // fall back to new session\n        if cerr != nil { return cerr }\n        _ = sess\n    }\n    return err\n}","preventionTips":["Copy session IDs from `crush sessions` output, not memory or logs.","Remember sessions are stored per data directory — same project, same user.","Do not wipe the crush data directory while scripts hold session IDs."],"tags":["go","session","cli","not-found"],"backgroundTag":"session-not-found","analyzedSha":"7944b8e52225d8805e31eacbf7ef24856b0dfb7a","analyzedAt":"2026-08-29T12:48:59.079Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}