{"record":{"id":"19901745ce2006b8","repo":"charmbracelet/crush","slug":"sessionlist-use-more-characters-or-the-full-has","errorCode":null,"errorMessage":"${sessionList}\nUse more characters or the full hash","messagePattern":"(.+?)\nUse more characters or the full hash","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cmd/session.go","lineNumber":257,"sourceCode":"\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\")\n\treturn session.Session{}, errors.New(sb.String())\n}\n\nfunc runSessionShow(cmd *cobra.Command, args []string) error {\n\tevent.SetNonInteractive(true)\n\n\tctx, svc, cleanup, err := sessionSetup(cmd)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer cleanup()\n\n\tevent.SessionShown(sessionShowJSON)\n\n\tsess, err := resolveSessionID(ctx, svc.sessions, args[0])\n\tif err != nil {\n\t\treturn err\n\t}\n","sourceCodeStart":239,"sourceCodeEnd":275,"githubUrl":"https://github.com/charmbracelet/crush/blob/7944b8e52225d8805e31eacbf7ef24856b0dfb7a/internal/cmd/session.go#L239-L275","documentation":"resolveSessionID builds this multi-line message when a session ID prefix is ambiguous — the given string is not a full UUID and matches the hash prefix of multiple sessions. Modeled after Git's short-hash behavior, it lists each matching session (12-char hash prefix, title, creation date) and tells the caller to supply more characters or the full hash.","triggerScenarios":"Passing a short hash prefix to crush session show/delete/rename or the run command's --session flag when two or more sessions share that prefix; e.g. two sessions whose HashIDs both start with 'a1b2'.","commonSituations":"Users copying only the first few characters of a session hash from a list; long-lived installs with many sessions increasing collision odds of short prefixes; scripts that truncate session IDs.","solutions":["Repeat the command with more characters of the hash, or use the full hash/UUID shown in the match list.","Pick the intended session from the printed matches (each shows a 12-char prefix, title, and creation date).","Use `crush sessions` to list all sessions with their full identifiers and copy the exact one."],"exampleFix":"// before\ncrush session delete a1b2\n// error: session ID 'a1b2' is ambiguous...\n// after\ncrush session delete a1b2c3d4e5f6","handlingStrategy":"validation","validationCode":"// Validate length before invoking session commands\nif len(sessionID) < 12 && !isUUID(sessionID) {\n    return fmt.Errorf(\"provide at least 12 hash chars or the full UUID, got %q\", sessionID)\n}","typeGuard":null,"tryCatchPattern":"if _, err := resolveSessionID(ctx, svc, id); err != nil && strings.Contains(err.Error(), \"is ambiguous\") {\n    // list the matches from err.Error() and re-prompt for a longer prefix\n}","preventionTips":["Copy full session UUIDs or at least 12+ hash characters from `crush sessions` output.","Avoid truncating session IDs in scripts and shell history.","When ambiguous, re-run with a longer prefix guided by the printed match list."],"tags":["cli","session","ambiguous-identifier"],"backgroundTag":"ambiguous-short-hash","analyzedSha":"7944b8e52225d8805e31eacbf7ef24856b0dfb7a","analyzedAt":"2026-08-29T12:48:59.079Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}