charmbracelet/crush · error
failed to rename session: %w
Error message
failed to rename session: %w
What it means
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.
Source
Thrown at internal/cmd/session.go:342
func runSessionRename(cmd *cobra.Command, args []string) error {
event.SetNonInteractive(true)
ctx, svc, cleanup, err := sessionSetup(cmd)
if err != nil {
return err
}
defer cleanup()
event.SessionRenamed(sessionRenameJSON)
sess, err := resolveSessionID(ctx, svc.sessions, args[0])
if err != nil {
return err
}
newTitle := strings.Join(args[1:], " ")
if err := svc.sessions.Rename(ctx, sess.ID, newTitle); err != nil {
return fmt.Errorf("failed to rename session: %w", err)
}
out := cmd.OutOrStdout()
if sessionRenameJSON {
enc := json.NewEncoder(out)
enc.SetEscapeHTML(false)
return enc.Encode(sessionMutationResult{
ID: session.HashID(sess.ID),
UUID: sess.ID,
Title: newTitle,
Renamed: true,
})
}
fmt.Fprintf(out, "Renamed session %s to %q\n", session.HashID(sess.ID)[:12], newTitle)
return nil
}
View on GitHub (pinned to 7944b8e522)
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
Example fix
// before crush session rename abc123 My New Name // after crush session rename abc123 "My New Name" # quote titles with spaces
Defensive patterns
Strategy: try-catch
Validate before calling
// pre-check writable DB and non-empty title
title := strings.Join(args[1:], " ")
if strings.TrimSpace(title) == "" {
return fmt.Errorf("new title must not be empty")
} Try / catch
if err := svc.sessions.Rename(ctx, sess.ID, newTitle); err != nil {
if errors.Is(err, sqlite.ErrLocked) {
return fmt.Errorf("database busy; close other crush sessions and retry: %w", err)
}
return fmt.Errorf("failed to rename session: %w", err)
} Prevention
- 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
When it happens
Trigger: svc.sessions.Rename(ctx, sess.ID, newTitle) errors: DB locked, read-only volume, constraint/scan error, or canceled context during the UPDATE.
Common situations: Another crush instance holding the SQLite write lock; data directory on a read-only mount; empty rename title causing an unexpected constraint failure.
Related errors
- failed to get session: %w
- error creating file history: %w
- failed to create session for non-interactive mode: %w
- failed to list sessions: %w
- failed to list messages: %w
AI-assisted analysis of charmbracelet/crush@7944b8e522 (2026-08-29).
Data as JSON: /api/errors/9c4bd8093c3e017e.
Report an issue: GitHub.