Skip to content

Bug: GET /api/sessions/:id returns 404 Session not found even with valid sessionId and cwd #18

Closed

Description

@dahai80

Problem

The /api/sessions/:id endpoint always returns {"error":"Session not found"} even when the session ID is valid and appears in the /api/sessions list.

Reproduction

# Session exists in list
curl "http://127.0.0.1:4827/api/sessions?cwd=/Users/dahai/fusion/fusion-code"
# Returns: sessions with sessionId "9f8bdb58-..."

# But detail returns 404
curl "http://127.0.0.1:4827/api/sessions/9f8bdb58-...?cwd=/Users/dahai/fusion/fusion-code"
# Returns: {"error":"Session not found"}

Root Cause

The /api/sessions list endpoint uses listSessionsImpl({dir: cwd}) which may resolve paths differently from the detail endpoint which uses:

const projectsDir = getProjectsDir();
const projectDir = join(projectsDir, sanitizePath(cwd));
const lite = await readSessionLite(projectDir, sessionId);

The sanitizePath(cwd) maps /Users/dahai/fusion/fusion-code to -Users-dahai-fusion-fusion-code, but listSessionsImpl may resolve the session directory differently (e.g., by scanning cwd directly or using a different path mapping).

Expected

Both endpoints should resolve to the same project directory and find the same sessions.

Environment

  • fusion-code v0.4.1, --serve mode
  • macOS 15.5, Apple Silicon

🤖 Generated with Claude Code

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions