Skip to content

fix(sandbox): bake safe.directory into image and surface chown failures - #83

Merged
dviejokfs merged 2 commits into
mainfrom
fix/custom-domains-refactor
May 10, 2026
Merged

dviejokfs merged 2 commits into
mainfrom
fix/custom-domains-refactor

Conversation

@dviejokfs

Copy link
Copy Markdown
Contributor

Summary

  • Adds git config --system --add safe.directory /home/temps/workspace to the sandbox Dockerfile generator so git pull inside a workspace doesn't fail with fatal: detected dubious ownership when the bind-mounted host workspace comes in owned by a uid other than the container's temps user (uid 1000) — common when the temps server runs as root or when userns-remap is enabled on the host Docker daemon.
  • Replaces three let _ = start_exec(...) post-start sites in DockerSandboxProvider::create_sandbox (home chown, work-dir chown, AI-CLI restore) with a new run_root_exec helper that drains the output stream, inspects the exit code, and logs stderr on non-zero. The two chown steps now fail sandbox creation if they fail, rather than leaving the user with a silently broken workspace; the AI-CLI restore stays best-effort but its exit code is logged.

Why

Production sandboxes were hitting git pull failures inside the workspace terminal:

fatal: detected dubious ownership in repository at '/home/temps/workspace'

Investigation showed /home/temps/workspace was still owned by 0:0 (root) inside the container despite the post-start chown logic — the chown exec was failing silently because of the swallowed let _ =. This change both prevents the symptom (Git trusts the workspace either way) and surfaces the underlying cause (chown failures now fail sandbox creation).

Deploy notes

The safe.directory bake-in only takes effect after sandbox images are rebuilt and pushed:

SANDBOX_CHANNEL=beta ./scripts/build-sandbox-images.sh    # beta
SANDBOX_CHANNEL=stable ./scripts/build-sandbox-images.sh  # stable promotion

The run_root_exec change ships with the next temps server release.

Test plan

  • cargo check --lib -p temps-agents passes
  • cargo test --lib -p temps-agents --no-run compiles tests
  • Build a beta sandbox image locally, start a sandbox, run git pull in the workspace — confirm no dubious-ownership error
  • Verify chown failure now fails sandbox creation visibly (induce by mocking exec failure or temporarily breaking CHOWN cap)

dviejokfs added 2 commits May 10, 2026 12:43
Sandboxes on production hosts hit `fatal: detected dubious ownership`
on `git pull` whenever the bind-mounted workspace inherited a uid other
than the container's `temps` user (uid 1000) — common when the host-side
temps server runs as root or when userns-remap is enabled on the Docker
daemon.

Two changes:

1. Dockerfile generator now runs `git config --system --add safe.directory
   /home/temps/workspace` while still root, so Git inside the sandbox
   trusts the workspace regardless of stat owner. Belt-and-suspenders
   against userns-remap and against the post-start chown failing.

2. Replaced three `let _ = start_exec(...)` sites that silently swallowed
   exec failures (home chown, work-dir chown, AI-CLI restore) with a new
   `run_root_exec` helper that drains the output stream, inspects the
   exit code, and logs stderr on non-zero. The two chown steps now fail
   sandbox creation if they fail (was: silent broken sandbox); the AI-CLI
   restore stays best-effort but its exit code is logged.
… fix

Adds a Fixed entry under [Unreleased] for PR #83 covering the two
behavior changes:
- `safe.directory` baked into sandbox image to avoid `git pull`
  dubious-ownership failures under userns-remap or root-owned mounts.
- New `run_root_exec` helper surfacing chown / AI-CLI restore exec
  failures that were previously swallowed by `let _ = start_exec(...)`.
@dviejokfs
dviejokfs merged commit 9063487 into main May 10, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant