{"record":{"id":"a8a692565f46ef6d","repo":"charmbracelet/crush","slug":"session-id-q-is-ambiguous-d-matches","errorCode":null,"errorMessage":"session ID %q is ambiguous (%d matches)","messagePattern":"session ID %q is ambiguous \\((.+?) matches\\)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cmd/root.go","lineNumber":965,"sourceCode":"\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\tswitch len(matches) {\n\tcase 0:\n\t\treturn session.Session{}, fmt.Errorf(\"session not found: %s\", id)\n\tcase 1:\n\t\treturn matches[0], nil\n\tdefault:\n\t\treturn session.Session{}, fmt.Errorf(\"session ID %q is ambiguous (%d matches)\", id, len(matches))\n\t}\n}\n\nfunc ResolveCwd(cmd *cobra.Command) (string, error) {\n\tcwd, _ := cmd.Flags().GetString(\"cwd\")\n\tif cwd != \"\" {\n\t\terr := os.Chdir(cwd)\n\t\tif err != nil {\n\t\t\treturn \"\", fmt.Errorf(\"failed to change directory: %v\", err)\n\t\t}\n\t\treturn cwd, nil\n\t}\n\tcwd, err := os.Getwd()\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to get current working directory: %v\", err)\n\t}\n\treturn cwd, nil\n}","sourceCodeStart":947,"sourceCodeEnd":983,"githubUrl":"https://github.com/charmbracelet/crush/blob/7944b8e52225d8805e31eacbf7ef24856b0dfb7a/internal/cmd/root.go#L947-L983","documentation":"Returned by resolveWorkspaceSessionID when the provided ID is a prefix that matches more than one session. The resolver only accepts an exact ID or an unambiguous prefix; a shared prefix is rejected to avoid resuming the wrong conversation.","triggerScenarios":"Passing a short prefix like `abc1` when two session IDs both start with `abc1` (common when many sessions share a naming pattern or were created in bulk).","commonSituations":"Scripts that truncate session IDs to a fixed length; many sessions auto-created during testing; copy-pasting only the first characters of a UUID.","solutions":["Pass the full session ID instead of a prefix","List sessions and pick the exact one you intend to resume","Delete or archive stale duplicate sessions to shorten unique prefixes","Use the session title if the CLI supports resolving by name"],"exampleFix":"// before: ambiguous prefix\ncrush run -s abc1 \"continue\"\n// after: full unambiguous ID\ncrush run -s abc1def2-3a4b-5c6d-7e8f-90a1b2c3d4e5 \"continue\"","handlingStrategy":"validation","validationCode":"matches := filterByPrefix(sessions, shortID)\nif len(matches) > 1 {\n\treturn fmt.Errorf(\"prefix %s is ambiguous; use the full ID\", shortID)\n}","typeGuard":null,"tryCatchPattern":"sess, err := resolveWorkspaceSessionID(id)\nif err != nil {\n\tif strings.Contains(err.Error(), \"ambiguous\") {\n\t\tslog.Error(\"Session prefix matches multiple sessions; pass the full ID\")\n\t}\n\treturn err\n}","preventionTips":["Always use full UUIDs in scripts and aliases","Avoid truncating session IDs to fixed lengths","Prune duplicate test sessions that share prefixes","Prefer resolving by unique session title where supported"],"tags":["session","ambiguous-id","cli"],"backgroundTag":"ambiguous-identifier","analyzedSha":"7944b8e52225d8805e31eacbf7ef24856b0dfb7a","analyzedAt":"2026-08-29T12:48:59.079Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}