Goal command hides underlying state DB errors

Resolved 💬 1 comment Opened May 16, 2026 by nwparker Closed May 16, 2026

Summary

When /goal fails in the TUI, the user-visible error can collapse to only:

Failed to set thread goal: thread/goal/set failed in TUI

In one reproduced case on codex-cli 0.130.0, the underlying app-server error was actually SQLite state corruption:

error returned from database: (code: 11) database disk image is malformed

That root cause was not visible from the TUI message, which made the failure look like a generic goal-mode bug.

Reproduction / diagnosis

Directly calling the app-server method against the affected Codex home produced:

thread/goal/set -> database disk image is malformed

The local state DB also failed integrity checks:

sqlite3 ~/.codex/state_5.sqlite 'PRAGMA integrity_check;'

with SQLite code 11 / malformed database output.

Verified workaround

After quitting Codex, moving these files aside fixed the local /goal failure:

~/.codex/state_5.sqlite
~/.codex/state_5.sqlite-shm
~/.codex/state_5.sqlite-wal

On restart, Codex recreated state_5.sqlite, backfilled from existing rollout sessions, and thread/goal/set, thread/goal/get, and thread/goal/clear all succeeded. A fresh PRAGMA integrity_check returned ok.

Expected behavior

The TUI should include the underlying app-server/source-chain error, so a user can distinguish corrupt local state from a generic goal command failure.

Related

This is related to #20598, but this issue captures a concrete root cause and verified workaround for one instance of the same visible TUI error.

Made with Orca 🐋

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗