Skip to content

Environment folder path outside the workspace volume breaks every attach with ACP "invalid directory path" #650

Closed

Description

@kayahk

Symptom

Every agent attach to a durable environment dies immediately:

executor: acp session attach (environment <id>): acp: session/new: Invalid params: invalid directory path

The conversation is recorded failed in milliseconds, the agent never runs, and nothing in the UI says which folder is wrong.

Cause

EnvironmentFolder.Path is what the api hands to the runner as the conversation's workdir, and the runner passes it as session/new's cwd. AddFolder only required a leading /, so any absolute path was accepted and handed to agent-runner's mkdir -p:

path := strings.TrimSpace(in.Path)
if !strings.HasPrefix(path, "/") {
    return nil, environmentdom.ErrFolderPathInvalid
}

A path outside the mounted workspace volume is created in the container's writable layer, not on the PVC. It works until the Pod is recreated and is then gone — so the folder row keeps pointing at a directory that no longer exists, and session/new rejects the cwd from then on. Observed live: a folder row at /home/paca-dev/workspaces (the environment mounts its PVC at /home/paca/workspaces), created while the environment was running. Reproduced against the environment's own agent-server with the same image:

  • session/new cwd=/home/paca-dev/workspaces → {"code":-32602,"message":"Invalid params","data":"invalid directory path"}
  • session/new cwd=/home/paca/workspaces/<sub> → sessionId returned

Browse and agent-runner's own mkdir/delete guards are already scoped to environmentHomeRoot (services/agent-runner/internal/acpbridge/environment_handlers.go) — the create path is the one place that was not.

Fix

  • AddFolder cleans the path and requires it to be environmentHomeRoot or under it, rejecting anything else with the existing ErrFolderPathInvalid (already mapped to 400 ENVIRONMENT_FOLDER_PATH_INVALID), and stores the cleaned path.
  • The folder-creation dialog's client-side pre-check uses the same root instead of "any absolute path", so the mistake is caught before submit.

A table test covers: root, subfolder, trailing slash, outside the volume, a sibling that only shares the prefix (/home/paca/workspaces-other), .. traversal out of the root, relative and empty paths.

Acceptance

  • A folder path outside /home/paca/workspaces returns 400 ENVIRONMENT_FOLDER_PATH_INVALID and creates no row.
  • Existing valid paths, including the workspace root itself, still create.
  • mkdir is never asked for a path that cannot survive a Pod recreation.

Rows already stored outside the root are not migrated by this change; they have to be corrected (or deleted) by hand, since the directory they name is gone too.

Activity

  1. pullfrog commented on Oct 28, 2026

    @pullfrog
    Contributor
  2. added
    bug
    good first issue
    on Oct 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    buggood first issue

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions