{"record":{"id":"9c4bd8093c3e017e","repo":"charmbracelet/crush","slug":"failed-to-rename-session-w","errorCode":null,"errorMessage":"failed to rename session: %w","messagePattern":"failed to rename session: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cmd/session.go","lineNumber":342,"sourceCode":"func runSessionRename(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.SessionRenamed(sessionRenameJSON)\n\n\tsess, err := resolveSessionID(ctx, svc.sessions, args[0])\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tnewTitle := strings.Join(args[1:], \" \")\n\tif err := svc.sessions.Rename(ctx, sess.ID, newTitle); err != nil {\n\t\treturn fmt.Errorf(\"failed to rename session: %w\", err)\n\t}\n\n\tout := cmd.OutOrStdout()\n\tif sessionRenameJSON {\n\t\tenc := json.NewEncoder(out)\n\t\tenc.SetEscapeHTML(false)\n\t\treturn enc.Encode(sessionMutationResult{\n\t\t\tID:      session.HashID(sess.ID),\n\t\t\tUUID:    sess.ID,\n\t\t\tTitle:   newTitle,\n\t\t\tRenamed: true,\n\t\t})\n\t}\n\n\tfmt.Fprintf(out, \"Renamed session %s to %q\\n\", session.HashID(sess.ID)[:12], newTitle)\n\treturn nil\n}\n","sourceCodeStart":324,"sourceCodeEnd":360,"githubUrl":"https://github.com/charmbracelet/crush/blob/7944b8e52225d8805e31eacbf7ef24856b0dfb7a/internal/cmd/session.go#L324-L360","documentation":"runSessionRename joins the remaining args into a new title and calls sessions.Rename. Failure of that DB update (wrapped here) aborts the rename. A missing session fails earlier in resolveSessionID, so this indicates a persistence-layer problem.","triggerScenarios":"svc.sessions.Rename(ctx, sess.ID, newTitle) errors: DB locked, read-only volume, constraint/scan error, or canceled context during the UPDATE.","commonSituations":"Another crush instance holding the SQLite write lock; data directory on a read-only mount; empty rename title causing an unexpected constraint failure.","solutions":["Close other running crush processes to release the write lock, then retry","Verify the data directory/filesystem is writable","Pass a non-empty new title (quote multi-word titles: crush session rename <id> \"New Title\")","Check the wrapped underlying error for the specific SQL failure"],"exampleFix":"// before\ncrush session rename abc123 My New Name\n// after\ncrush session rename abc123 \"My New Name\"   # quote titles with spaces","handlingStrategy":"try-catch","validationCode":"// pre-check writable DB and non-empty title\ntitle := strings.Join(args[1:], \" \")\nif strings.TrimSpace(title) == \"\" {\n    return fmt.Errorf(\"new title must not be empty\")\n}","typeGuard":null,"tryCatchPattern":"if err := svc.sessions.Rename(ctx, sess.ID, newTitle); err != nil {\n    if errors.Is(err, sqlite.ErrLocked) {\n        return fmt.Errorf(\"database busy; close other crush sessions and retry: %w\", err)\n    }\n    return fmt.Errorf(\"failed to rename session: %w\", err)\n}","preventionTips":["Quote multi-word titles in the shell to get a single argument","Stop other crush processes before renaming","Verify the data dir is on a writable mount","Pass a non-empty, trimmed title"],"tags":["go","sqlite","session","update"],"backgroundTag":"database-write-failed","analyzedSha":"7944b8e52225d8805e31eacbf7ef24856b0dfb7a","analyzedAt":"2026-08-29T12:48:59.079Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}