Skip to content

fix: refuse a blank or NUL session name with UnsupportedOptionError - #372

Merged
xxchan merged 1 commit into
mainfrom
fix/session-name-validation
Oct 12, 2026
Merged

xxchan merged 1 commit into
mainfrom
fix/session-name-validation

Conversation

@xxchan

@xxchan xxchan commented Oct 12, 2026

Copy link
Copy Markdown
Member

Found by Lookout's daily inspection of 0.59.0 (#369).

  • A blank SessionOptions.name threw a plain Error. Invalid additionalDirectories throw UnsupportedOptionError naming the option, so a host that catches by type missed the name case.
  • A name with a NUL character reached claude's command line and failed in Node's spawn ("The argument 'args[12]' must be a string without null bytes").

Both now reject with UnsupportedOptionError on name before anything starts, on claude, codex and pi (the runtimes that take a name), with the message name must not be blank or contain NUL characters. Docs and the SessionOptions comment say so.

Behavior change: a blank name's error is now an UnsupportedOptionError instead of a plain Error. Released in 0.59.0 earlier today.

Validation: tests/refused-session-options.test.ts covers "", " " and "a\0b" on claude, codex and pi. Typecheck, lint and the full unit suite (1754 tests) pass.

🤖 Generated with Claude Code

Lookout's inspection: a blank SessionOptions.name threw a plain Error,
while invalid additionalDirectories throw UnsupportedOptionError, so a
host catching by type missed it; and a name with a NUL reached claude's
command line and failed in Node's spawn. Both are now
UnsupportedOptionError on `name`, before anything starts.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@xxchan
xxchan merged commit a34e670 into main Oct 12, 2026
17 checks passed
@xxchan
xxchan deleted the fix/session-name-validation branch October 12, 2026 10:48
@xxchan xxchan mentioned this pull request Oct 12, 2026
xxchan added a commit that referenced this pull request Oct 12, 2026
Release OAR and CLI 0.59.1. This PR changes only the two package version
fields.

**Fixed: invalid session names are an `UnsupportedOptionError`** (#372)
- A blank `SessionOptions.name`, or one with a NUL character, now
rejects with `UnsupportedOptionError` on `name` before anything starts,
as invalid `additionalDirectories` already do. This applies on claude,
codex and pi, the runtimes that take a name.
- In 0.59.0 a blank name threw a plain `Error`, which a host catching by
type missed. A name with a NUL reached claude's command line and failed
in Node's spawn.

**Behavior change**
- A blank name's error is now `UnsupportedOptionError` instead of a
plain `Error`.

Validation: #372 passed all 17 checks on its final head, and its merged
tree equals its CI tree. Found by Lookout's daily inspection of 0.59.0.
After this PR passes CI and merges, tag its exact squash commit as
`v0.59.1` to trigger npm trusted publishing.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: exe.dev user <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
stamp-build Bot added a commit that referenced this pull request Nov 20, 2026
…-lived queries, document EOF rule and codex#62688 (#1074)

<!-- stamp:review:v1 -->
<sup><img src="https://api.raft.build/api/avatars/pixel/ZXll.svg"
width="16" height="16" align="absmiddle" alt=""> <b>Lookout</b> from
open-agent-runtime opened this pull request through
Stamp</sup><br><sup><a
href="https://stamp.build/review?receipt=prc_6709b13d383e9f3221135d12979ab4b2"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://stamp.build/assets/brand/stamp-glyph-dark.d907ffcadb44.svg"><img
src="https://stamp.build/assets/brand/stamp-glyph-light.58a2c10ed108.svg"
width="13" height="12" align="absmiddle" alt=""></picture> View in Stamp
→</a></sup>

---
<!-- /stamp:review:v1 -->

## Summary

Follow up on `#core:#371` / PR #1061 (`#core:#372`) by routing Codex
short-lived queries and idle session disposal plus Factory's ACP account
process through stdin EOF shutdown (`shutdown: "stdin"` /
`closeLineProcess`), documenting the stdin-EOF eligibility rule in
`docs/development.md`, and linking `openai/codex#62688` in
`docs/runtimes/codex.md`.

## Changes & Measured EOF Evidence

- **Codex (`packages/oar/src/runtimes/codex/app-server-client.ts`,
`home-initialization.ts`, `session.ts`, `account-request.ts`,
`account-usage.ts`, `list-models.ts`, `inventory.ts`, `login.ts`):**
- Added `shutdown` to `AppServerProcessOptions` and `close()` (calling
`closeLineProcess(child)`) to `AppServerClient` and `queuedClient`.
- Idle `codexSession.dispose()` now uses `await client.close()` (stdin
EOF with `killGraceMs()` fallback), while an active turn or manual
compaction still kills immediately (`client.kill(); await
client.exited;`), matching Claude/Qoder/Qwen.
- Short-lived Codex `app-server` queries (`accountUsage`,
`redeemLimitReset`, `listModels`, inventory) pass `shutdown: "stdin"`;
`codexLogin` uses `await app.close()` (stdin EOF) on normal completion
while keeping immediate `app.kill()` on cancel, timeout, or interaction
failure so polling workers stop without waiting for `killGraceMs()`.
- **Measured EOF exit (`#core:#371` audit):** `codex app-server`
(`0.170.0` and `0.171.0`) exits cleanly (`code 0`) in 8 to 54 ms on
stdin EOF (18 ms on `0.171.0`).
  - Regression tests: `tests/codex/codex-shutdown.test.ts`.
- **Factory (`packages/oar/src/runtimes/factory/account.ts`):**
- Added `shutdown: "stdin"` to `withDroidAcp`'s `spawnLineProcess`
(matching `factory/client.ts:73`).
- **Measured EOF exit (`#core:#371` audit):** `droid exec
--output-format acp` (`1.16.0`) runs `owner-loss` -> `dispose()` and
exits cleanly (`code 0`, 723 ms) on stdin EOF.
  - Regression test: `tests/factory/factory-account-shutdown.test.ts`.
- **Docs (`docs/development.md`, `docs/runtimes/codex.md`):**
- `docs/development.md`: added the rule that stdin EOF shutdown
(`shutdown: "stdin"` / `closeLineProcess`) may only be used on runtimes
measured to exit on stdin EOF; runtimes that stay open on EOF (such as
CodeBuddy `--acp`) must not use it, and shared `startAcpProcess` must
not enable it globally.
- `docs/runtimes/codex.md`: documented idle EOF disposal, short-lived
query EOF shutdown, and linked
`https://github.com/openai/codex/issues/62688` noting that dropping an
in-flight background `/oauth/token` refresh on exit (both stdin EOF and
`SIGTERM`) is upstream Codex behavior (observed on `0.171.0`) that clean
EOF shutdown from OAR cannot prevent.

## Call-Site Audit

- **`startAppServerClient` (`packages/oar/src/runtimes/codex/`):**
Checked all 5 callers (`session.ts`, `account-request.ts`,
`list-models.ts`, `inventory.ts`, `login.ts`): idle session `dispose()`
uses `closeLineProcess`, active turn `dispose()` keeps immediate
`kill()`, `login.ts` uses `close()` on normal completion and `kill()` on
cancel/timeout/interaction failure, and all 3 short-lived query callers
(`account-request.ts`, `list-models.ts`, `inventory.ts`) pass `shutdown:
"stdin"`.
- **Factory `spawnLineProcess`:** Checked both call sites
(`factory/client.ts:73` already had `shutdown: "stdin"`;
`factory/account.ts:46` now adds `shutdown: "stdin"`).
- **Unchanged by design (negative constraint):** `codebuddy --acp`
(`2.173.0`) was measured staying open past 5 s on stdin EOF, so
`shared/acp/process.ts` (`startAcpProcess`) is intentionally NOT changed
globally.

## Verification

- Local `CI=1 pnpm run check` on rebased head `e841fbed` (base
`ce5a24b3`): `typecheck` passed, `oxlint --type-aware --deny-warnings` 0
errors / 0 warnings, `vitest run` 589 passed / 147 skipped (5541 passed
/ 703 skipped), mock `sea-trial` 19 passed / 1 skipped / 0 failed.

Co-authored-by: Lookout <[email protected]>
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