charmbracelet/crush · error

session not found: %s

Error message

session not found: %s

What it means

Returned by resolveWorkspaceSessionID when no stored session matches the given ID (full ID or unique prefix). The function collects workspace sessions whose ID or prefix equals the input; zero matches means the session does not exist in this workspace's database.

Source

Thrown at internal/cmd/root.go:961

		return sess, nil
	}

	sessions, err := ws.ListSessions(ctx)
	if err != nil {
		return session.Session{}, err
	}

	var matches []session.Session
	for _, s := range sessions {
		hash := session.HashID(s.ID)
		if hash == id || strings.HasPrefix(hash, id) {
			matches = append(matches, s)
		}
	}

	switch len(matches) {
	case 0:
		return session.Session{}, fmt.Errorf("session not found: %s", id)
	case 1:
		return matches[0], nil
	default:
		return session.Session{}, fmt.Errorf("session ID %q is ambiguous (%d matches)", id, len(matches))
	}
}

func ResolveCwd(cmd *cobra.Command) (string, error) {
	cwd, _ := cmd.Flags().GetString("cwd")
	if cwd != "" {
		err := os.Chdir(cwd)
		if err != nil {
			return "", fmt.Errorf("failed to change directory: %v", err)
		}
		return cwd, nil
	}
	cwd, err := os.Getwd()
	if err != nil {

View on GitHub (pinned to 7944b8e522)

Solutions

  1. Run `crush sessions` (or list in the TUI) to see valid IDs for this workspace
  2. Verify you are in the same project directory whose .crush DB holds the session
  3. Check the ID for typos, whitespace, or case mismatches
  4. If the session is gone, start a new session instead of resuming

Example fix

// before: resuming with a hand-copied ID
crush run -s abc123de "fix the bug"
// after: resolve the ID from the sessions list first
crush sessions   # find the correct full ID
crush run -s abc123de-4f5e-6789 "fix the bug"
Defensive patterns

Strategy: validation

Validate before calling

sessions := listWorkspaceSessions() // from `crush sessions`
if len(filterByPrefix(sessions, id)) == 0 {
	return fmt.Errorf("session %s does not exist in this workspace", id)
}

Try / catch

sess, err := resolveWorkspaceSessionID(id)
if err != nil {
	if strings.HasPrefix(err.Error(), "session not found") {
		slog.Error("Unknown session ID; run 'crush sessions' to list valid IDs", "id", id)
	}
	return err
}

Prevention

When it happens

Trigger: Passing a session ID that was deleted, belongs to a different workspace/project directory, or contains a typo; using a session from an old .crush directory after it was recreated.

Common situations: Switching projects and reusing a remembered session ID; cleaning .crush data directories; resuming sessions from another machine; pasted IDs with extra whitespace or wrong case.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of charmbracelet/crush@7944b8e522 (2026-08-29). Data as JSON: /api/errors/e265b35b51d665a0. Report an issue: GitHub.