{"record":{"id":"fbda30123b102bdb","repo":"charmbracelet/crush","slug":"session-not-found-s-fbda30","errorCode":null,"errorMessage":"session not found: %s","messagePattern":"session not found: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cmd/session.go","lineNumber":238,"sourceCode":"\t\treturn s, nil\n\t}\n\n\t// List all sessions and check for hash matches\n\tsessions, err := svc.List(ctx)\n\tif err != nil {\n\t\treturn session.Session{}, err\n\t}\n\n\tvar matches []session.Session\n\tfor _, s := range sessions {\n\t\thash := session.HashID(s.ID)\n\t\tif hash == id || strings.HasPrefix(hash, id) {\n\t\t\tmatches = append(matches, s)\n\t\t}\n\t}\n\n\tif len(matches) == 0 {\n\t\treturn session.Session{}, fmt.Errorf(\"session not found: %s\", id)\n\t}\n\n\tif len(matches) == 1 {\n\t\treturn matches[0], nil\n\t}\n\n\t// Ambiguous - show matches like Git does\n\tvar sb strings.Builder\n\tfmt.Fprintf(&sb, \"session ID '%s' is ambiguous. Matches:\\n\\n\", id)\n\tfor _, m := range matches {\n\t\thash := session.HashID(m.ID)\n\t\tcreated := time.Unix(m.CreatedAt, 0).Format(\"2006-01-02\")\n\t\t// Keep title on one line by replacing newlines with spaces, and truncate.\n\t\ttitle := strings.ReplaceAll(m.Title, \"\\n\", \" \")\n\t\ttitle = ansi.Truncate(title, 50, \"…\")\n\t\tfmt.Fprintf(&sb, \"  %s... %q (created %s)\\n\", hash[:12], title, created)\n\t}\n\tsb.WriteString(\"\\nUse more characters or the full hash\")","sourceCodeStart":220,"sourceCodeEnd":256,"githubUrl":"https://github.com/charmbracelet/crush/blob/7944b8e52225d8805e31eacbf7ef24856b0dfb7a/internal/cmd/session.go#L220-L256","documentation":"resolveSessionID lets users pass a full session ID or a unique hash prefix. After scanning all sessions, if no session's ID (or hash prefix) matches the given argument, this 'session not found' error is returned. It is a user-input error, not a system failure.","triggerScenarios":"`crush session show|delete|rename <id>` called with an ID/prefix that matches zero sessions — typo, session already deleted, or wrong data directory (different DB).","commonSituations":"Copy-pasting an ID from another machine's data dir; truncating a hash prefix so it matches nothing; referencing a session deleted earlier; case-sensitivity mismatch in the prefix.","solutions":["Run `crush session list` (or with --json) to see valid session IDs and copy one exactly","Check you are pointing at the same --data-dir used when the session was created","Verify the prefix is long enough and matches at least one session hash","If ambiguous vs missing confusion matters, note that multiple matches raise a separate ambiguity error — this one means zero matches"],"exampleFix":"// before\ncrush session show abc12\n// after\ncrush session list            # find the correct ID\ncrush session show abc123def456...   # use full/valid ID","handlingStrategy":"validation","validationCode":"// validate the ID against the session list before resolving\nlist, _ := svc.sessions.List(ctx)\nid := args[0]\nfound := false\nfor _, s := range list {\n    if s.ID == id || strings.HasPrefix(strings.TrimPrefix(s.ID, \"session_\"), id) {\n        found = true\n        break\n    }\n}\nif !found {\n    return fmt.Errorf(\"unknown session %q; run 'crush session list' to see valid IDs\", id)\n}","typeGuard":null,"tryCatchPattern":"sess, err := resolveSessionID(ctx, svc.sessions, args[0])\nif err != nil {\n    var nfErr *NotFoundError\n    if errors.As(err, &nfErr) {\n        fmt.Fprintf(os.Stderr, \"No session matching %q. Try 'crush session list'.\\n\", args[0])\n        os.Exit(1)\n    }\n    return err\n}","preventionTips":["Copy full session IDs from `crush session list --json` rather than typing prefixes","Confirm the --data-dir matches where the session was created","Tab-complete or script ID resolution against the live list","Remember deleted sessions disappear from the ID space"],"tags":["go","cli","session","user-input"],"backgroundTag":"resource-not-found","analyzedSha":"7944b8e52225d8805e31eacbf7ef24856b0dfb7a","analyzedAt":"2026-08-29T12:48:59.079Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}