Skip to content

fix(codex): a snapshot leaves out links that leave the workspace, and names why an archive fails - #895

Open
andrewpark-scaleai wants to merge 2 commits into
mainfrom
andrew-park/codex-snapshot-outside-links
Open

andrewpark-scaleai wants to merge 2 commits into
mainfrom
andrew-park/codex-snapshot-outside-links

Conversation

@andrewpark-scaleai

@andrewpark-scaleai andrewpark-scaleai commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Problem. The Codex agent's snapshot save failed with a bare HTTP 500 whenever its workspace held a symlink that is absolute or resolves outside the workspace. An agent that symlinks a tool from elsewhere in the container into the workspace (ln -s /usr/local/lib/.../bin/tool /app/work/tool) hits this every time, so the run loses its workspace snapshot. The archive step raised a ValueError that no handler mapped, and the worker keeps only an SDK error code from an error body, so its log read just snapshot save failed with HTTP 500.

Change.

  • The workspace archive leaves out a link that is absolute or resolves outside the workspace, and logs a warning naming the link and its target. A restore already refuses such a link, so keeping it in the archive would only move the failure to load time. Links that stay inside the workspace are archived as before.
  • Every other archive failure (an unsupported entry, too many entries, a size limit) stays a failure, but now answers 422 with the SDK error body and the code workspace_unarchivable, raised as an AgentEnvError. The message carries the reason, and the agent logs it too. The worker reports snapshot save failed with HTTP 422: workspace_unarchivable.

No other agent has this check; the Claude Code and Gemini saves are unchanged.

Validation. Codex unit tests pass (tst/unit/agents/codex, 255 tests), as do tst/unit/agents and tst/unit/a2a_agent (1631 tests), and ruff check. New tests drive /ext/snapshot against a fake object store:

  • A workspace with an absolute link out, a relative link that escapes, an in-workspace link and a file saves with 200. The archive omits both outside links, keeps the file and the in-workspace link, and loads back.
  • A workspace over the member limit answers 422 with workspace_unarchivable, uploads nothing, and raise_for_extension_status turns it into snapshot save failed with HTTP 422: workspace_unarchivable.

Both new tests fail on main with a 500. The archive-level test that expected an absolute link to raise now expects the link to be left out.

🤖 Generated with Claude Code

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge; the previous restore failure is fixed and no new actionable issues were found.

Summary

Codex snapshots skip links that restore cannot safely keep and return workspace_unarchivable when archive limits or unsupported entries prevent saving.

  • Codex snapshots omit links that leave the workspace.
  • Codex snapshot errors name why a workspace archive failed.

Reviews (2) · Last reviewed commit: "fix(codex): a snapshot keeps only links ..." · Reviewed by Greptile

@andrewpark-scaleai
andrewpark-scaleai requested a review from a team as a code owner November 23, 2026 19:58
… names why an archive fails

A save failed with a bare HTTP 500 whenever the workspace held a symlink that is
absolute or resolves outside it, such as an agent linking a tool from elsewhere in
the container into the workspace. The worker logged only the status, so the cause
was invisible.

The archive now skips such a link and logs a warning naming it; a restore refuses
those links anyway. Links inside the workspace are kept. Every other archive
failure (an unsupported entry, too many entries, a size limit) answers 422 with the
code workspace_unarchivable, which the worker reports as
"snapshot save failed with HTTP 422: workspace_unarchivable".
A save decided whether to keep a relative link by resolving it in the live
workspace, which still holds the links the save leaves out. A link that climbs
out of another link, such as `kept -> alias/../../target` beside an absolute
`alias`, was kept, and the restore then refused the whole archive.

The save now walks each link's target lexically from the link's folder. It
keeps the link only when the walk never leaves the workspace and never takes
`..` after passing another link, so no other link, kept or left out, extracted
yet or not, can move the restore's resolve outside. A link in a loop is left out
too, since the restore's resolve raises on it. Links that only descend through
another link, as package managers' bin links do, are still kept.
@andrewpark-scaleai
andrewpark-scaleai force-pushed the andrew-park/codex-snapshot-outside-links branch from be41551 to 87138ba Compare November 23, 2026 20:11

This branch has not been deployed

No deployments
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