Skip to content

feat: report nsjail failures as errors and self-check nsjail at startup - #95

Merged
koki-develop merged 2 commits into
mainfrom
claude/project-thread-7w044w
Dec 1, 2026
Merged

koki-develop merged 2 commits into
mainfrom
claude/project-thread-7w044w

Conversation

@koki-develop

Copy link
Copy Markdown
Member

Before: When nsjail itself fails (for example, it cannot set up the jail), it exits 255 and the API returns that as the program's result: {"run":{"exit_code":255,"status":"OK",...}} with HTTP 200, and no error is logged. On a host where nsjail cannot run programs, the server starts and /healthz stays ok while every run fails this way.

After: Such a request, in the compile or the run step, returns HTTP 500 {"code":"INTERNAL_ERROR","message":"internal server error"}, and the server logs sandbox execution failed with nsjail's error lines. On startup the server runs a one-line bash script through nsjail; if it does not print the expected output and exit 0, the server logs sandbox self-check failed with the reason and exits.

A program that exits 255 itself is still returned as a result with exit_code: 255.

How: nsjail's own output tells the two apart. When launching the program fails, nsjail logs Couldn't launch the child process (and still logs the child as exited or killed afterwards); when nsjail fails before launching it, or is killed from outside, its log has no exited with status or terminated with signal line. The error lines are taken from the log and from nsjail's stderr, where it writes until it has read its config.

flowchart LR
  A[nsjail exits non-zero] --> B{"log has<br/>Couldn't launch the child process?"}
  B -- yes --> E[error → HTTP 500]
  B -- no --> C{"log has exited with status<br/>or terminated with signal?"}
  C -- no --> E
  C -- yes --> R[program's result]
Loading

Generated by Claude Code

When nsjail could not set up the jail or launch the program, it exits 255
and that status was returned as the program's exit code with status OK.
Tell nsjail's own failure apart from its log and return it as an error
(HTTP 500, with nsjail's error lines in the server log), and run a small
bash program through nsjail at startup so that a host where nsjail cannot
run programs refuses to serve.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@koki-develop
koki-develop merged commit 253cd65 into main Dec 1, 2026
8 checks passed
@koki-develop
koki-develop deleted the claude/project-thread-7w044w branch December 1, 2026 02:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants