Repository navigation
Description
Summary
Codex Desktop on Windows writes ~/.codex/config.toml non-atomically and without FlushFileBuffers. If the OS loses power (or is force-rebooted) between the moment Codex's write() returns and the moment NTFS flushes the dirty page cache to disk, NTFS commits the file's new size to the directory metadata but never writes the data clusters. Per the file-system's zero-fill-on-read security policy, the file then reads as uniform 0x00 bytes from byte 0 to EOF, blowing away every user customization (plugins, MCP servers, sandbox mode, model settings, trusted projects).
On next launch Codex bails with:
failed to load configuration: C:\Users\<user>\.codex\config.toml:1:<size+1>: key with no value, expected `=`
because the TOML parser walks N NUL bytes as one runaway bare key and hits EOF without finding =.
Reproduction
- On Windows 10/11, launch Codex Desktop and let it write
config.toml(any settings change, plugin install, or[projects.*]trust prompt will do). - Within ~30s of the write — before Windows' lazy writeback flushes the page cache — cut power (or hold the power button until the machine shuts down hard).
- Boot back up, launch Codex Desktop.
- Expected: previous config loads, or Codex falls back to defaults cleanly.
- Actual:
~/.codex/config.tomlisNbytes of0x00. Codex refuses to start with the parse error above. The "Use backup sandbox" button doesn't fix it because that only swaps sandbox mode — the parser fails before sandbox setup even runs.
Forensic evidence from one occurrence
File: C:\Users\<user>\.codex\config.toml
Size: 4183 bytes
First 16 bytes: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Last 16 bytes: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
LF count: 0
CR count: 0
NUL count: 4183
Unique byte values across whole file: { 0x00 }
File mtime matched the user's last Codex action ~5 minutes before the power loss. Three sibling files in .codex/ (AGENTS.md, auth.json, chrome-native-hosts-v2.json) were untouched by the same crash window because they hadn't been re-written that session — they survived intact.
Root cause
This is the classic ext4 zero-after-crash pattern, just on NTFS. Codex's persistence path appears to be a straight open(path, O_TRUNC) → write() → close(), without:
- writing to a temp file (
config.toml.tmp), FlushFileBuffers(handle)to force the dirty cache to disk,MoveFileEx(tmp, dst, MOVEFILE_WRITE_THROUGH | MOVEFILE_REPLACE_EXISTING)for atomic replace.
Without these, the durability guarantee Codex appears to depend on doesn't exist on Windows.
Suggested fix
Adopt write-temp-then-rename atomic semantics for config.toml (and any other crash-critical files in ~/.codex/, e.g. auth.json, .codex-global-state.json, chrome-native-hosts-v2.json):
// pseudocode
let tmp = path.with_extension("toml.tmp");
{
let mut f = File::create(&tmp)?;
f.write_all(contents.as_bytes())?;
f.sync_all()?; // FlushFileBuffers under the hood on Windows
}
// On Windows: MoveFileExW(tmp, path, MOVEFILE_REPLACE_EXISTING | MOVEFILE_WRITE_THROUGH)
// On POSIX: rename(tmp, path)
fs::rename(tmp, path)?;This makes the worst possible crash leave either the old intact file or the new intact file on disk — never a zero-filled phantom.
Secondary observation (separate, possibly related)
When a user hits this and clicks "Use backup sandbox", Codex tries to set up the elevated admin sandbox, which on some machines fails with "Couldn't set up admin sandbox" (see #14808, #23249). That makes the "Use backup sandbox" recovery path effectively a dead end for affected users — they have to fix the config file manually before Codex will boot at all.
Workaround for currently-affected users
- Move the zeroed file aside:
Move-Item ~/.codex/config.toml ~/.codex/config.toml.corrupt - If you've ever shared a session that included a
Get-Content config.tomlagent call, your old config may be recoverable from the JSONL rollout file. - Otherwise: start Codex with an empty config, set
[windows] sandbox = "unelevated"if you hit the secondary sandbox bug, re-trust your projects on demand.
Environment
- OS: Windows 11 Pro 10.0.26200
- Codex Desktop: latest as of 2026-06-04
- Reproduction trigger: power loss during a Codex session
Activity
alexdresko commentedon Jun 4, 2026
My codex app just crashed and I lost ALL of my projects and conversations.
gNikro commentedon Jul 8, 2026
Additional occurrence on Windows after an abrupt restart / forced reboot, on a newer Codex Desktop build.
Environment:
User-visible symptom:
Logs contained repeated entries:
Forensic evidence:
So both the manually saved broken config and the adjacent backup TOML were fully zero-filled, not merely syntactically malformed.
Impact in this occurrence:
{"schemaVersion":1,"projects":[]}.state_5.sqlite/list_threads; several private local workspaces were visible there, so session data was not fully lost.codex mcp listreturnedNo MCP servers configured yet.Recovery performed locally:
%USERPROFILE%\.codex\config.tomlfrom surviving active defaults, session history, project-local.codex/config.tomlfiles, VS Codemcp.json, and old rollout evidence.[projects.*]entries usingstate_5.sqlitethreadcwdvalues.tomllib.codex mcp listafter repair:This reinforces the original report: config writes need crash-safe atomic temp-file + flush + rename semantics on Windows, and Codex should preserve a last-known-good config or auto-recover from project/thread state instead of falling back to defaults and losing MCP/project settings after a single corrupted TOML write.
Related broader state-loss issue: #26990
cyanlink commentedon Jul 25, 2026
Additional occurrence on Windows, with a newer Desktop build and no known power loss or forced shutdown.
Environment / timing:
The app appeared normal the previous day. After the update/relaunch, the initial user-visible symptom was that all projects disappeared from the sidebar.
Recovery behavior was unusual:
Forensic evidence then showed:
The app-server error was:
An adjacent backup of the config was also uniformly NUL-filled, so it had no recovery value.
The project/conversation data itself was not deleted:
state_5.sqlitestill contained the local threads and their workspacecwdvalues..codex-global-state.jsonhad collapsed to a one-project state.2026-07-13-local-projectsand2026-07-14-repair-metadata-local-projects), so restarting alone did not rebuild the sidebar.Local recovery required fully exiting Codex, replacing the invalid config, and reconstructing the project/global-state JSON from surviving pre-migration state plus
state_5.sqlite. Both the primary global-state file and its adjacent backup had to be repaired before restart. After that, all 8 projects and their conversations returned and could be opened.This looks like the same zero-filled
config.tomlfailure described in this issue, combined with the broader project/sidebar state loss tracked in #26990. The important difference is that this occurrence was correlated with a Desktop update/relaunch rather than a known power-loss event. The “Finish Windows setup” prompt also appears to be a misleading downstream symptom: invalid config/default fallback prevented normal Desktop settings and Windows sandbox initialization while the durable thread data remained present.No raw logs, full config, project names, prompts, tokens, or private paths are included here. I can provide specific redacted diagnostics if maintainers identify the fields needed.
Gamooly commentedon Sep 9, 2026
Additional occurrence on September 9, 2026, on a substantially newer Codex Desktop build. I also have some implementation evidence that may refine the original root-cause hypothesis.
Environment:
Observed corruption:
The resulting parser error was:
The user-visible symptoms progressed through:
Restoring a valid same-day Windows Previous Versions snapshot of
config.tomlimmediately recovered the application.config/read,configRequirements/read, and Windows sandbox readiness all returned to normal afterward.There was also a second independently generated Codex file from the same startup sequence:
The preserved
.mcp.jsoncreation timestamp is 3 ms earlier than the preservedconfig.tomltimestamp.An important timing detail:
config/readstill succeeded several seconds after those file creation timestamps. The first surviving explicit TOML parse failure occurs only after a later unclean boot. Therefore I cannot establish that the files became zero-filled at the moment they were created.All timeline times below are EDT (UTC-04:00).
Windows timeline around the event included:
The owner was intentionally changing NVMe slot configuration during this period. The surviving logs do not establish whether the later unclean shutdown was an interrupted intentional shutdown, a hang, power removal, or another failure.
I inspected the currently installed Desktop bundle and version-matched 0.153.4 backend source.
There are multiple config persistence paths:
fs/promises.writeFile(config.toml, ...)path with no temporary replacement or explicit flush. However, that helper loggedalready-presentimmediately before this occurrence, so that particular invocation does not appear to be the writer here.config/batchWrite..mcp.jsonis written to a temporary sibling and renamed over the destination.NamedTempFile -> write_all -> persist(destination).The backend atomic-write path contains no explicit
sync_all/fsyncbeforepersist. The version-matched config writer is here: https://raw.githubusercontent.com/openai/codex/rust-v0.153.4/codex-rs/utils/path-utils/src/lib.rsThe matching
tempfileWindows implementation usesMoveFileExW(..., MOVEFILE_REPLACE_EXISTING)and does not addMOVEFILE_WRITE_THROUGHor callFlushFileBuffers: https://raw.githubusercontent.com/Stebalien/tempfile/v3.27.0/src/file/imp/windows.rsBoth preserved files are entirely NUL-filled, and their creation timestamps are only 3 ms apart. Subsequent config/read requests still succeeded. This supports investigating durability of the startup replacement sequence, but does not establish when either file became zero-filled or prove which write path caused the corruption.
In other words, atomic replacement prevents readers from observing a partially serialized file, but without an explicit durability flush it may still be possible for an unclean shutdown to lose recently written cached payload data.
Other possible causes were investigated:
Both corrupt originals are preserved.
This looks like another current-build occurrence of the failure signature in this issue, but with evidence suggesting maintainers may also want to review durability guarantees around the temp-file + rename path.
The startup symptoms also resemble #34126 and #38500.
No raw logs, configuration contents, project names, prompts, tokens, credentials, or private user paths are included here. I can provide additional narrowly redacted diagnostics if maintainers need a specific field.
walterdalec commentedon Sep 11, 2026
Confirming this issue is still occurring on Windows with Codex Desktop 26.903.9818.0 as of September 10, 2026.
Symptoms
Codex showed the splash/logo screen, then opened to a blank white window.
UI elements briefly flashed every few seconds.
Updating/reinstalling the application did not resolve the problem.
The desktop logs repeatedly reported:
failed to read configuration layers:
C:\Users<user>.codex\config.toml:1:6511:
key with no value, expected
=The same error affected config requirements, permissions, feature enablement, plugins, and MCP startup. Authentication itself was succeeding.
I inspected ~/.codex/config.toml directly:
Character length: 6510
File byte length: 6510
Line count: 1
Format-Hex showed that the entire file consisted of 0x00 bytes. All 6,510 bytes had been replaced with NUL characters.
The parser error therefore occurs at position 6511, immediately after the end of the zero-filled file.
Recovery
With Codex closed, I renamed the corrupted configuration:
Rename-Item "$env:USERPROFILE.codex\config.toml" "config.toml.corrupt"
After relaunching Codex, the desktop application immediately loaded normally and presented the onboarding screen. After completing onboarding, projects/workspaces and normal functionality appeared intact.
This machine had experienced significant system instability around the time the problem began, so this may be related to an interrupted/non-atomic write of config.toml.
Updating Codex did not resolve the issue because the corrupted file persisted in the user profile across application updates.
It may be worth protecting config.toml writes with an atomic temp-file + rename operation and/or detecting a NUL-filled/unparseable config at startup and automatically falling back to a backup/default configuration instead of leaving the desktop UI unusable.
fix: sessions missing or unresumable after a provider switch
feat: rebuild sessions lost to zero-filled rollout files
tedparkes commentedon Oct 11, 2026
Title: Windows local chat transcript permanently zero-filled after BSOD; repeated zero-filled config.toml
Summary
A Windows Codex Desktop user experienced repeated BSODs and had to replace
config.toml more than once. One local chat cannot be resumed because its rollout
JSONL is 108,753 bytes of 0x00. This is persistent loss of transcript content,
not an empty-file startup race: two later Windows Previous Versions snapshots
contain exactly the same all-zero file, and local projected history contains
no records from which to rebuild that chat.
Environment observed on October 11, 2026
not claim Codex caused the BSODs or establish a hardware/software root cause.
Observed data loss
Those timestamps alone do not establish the corruption time or causal writer.
rollout file is empty.
transcript copies. Neither snapshot's thread_history database contains items,
turns, or realtime items for the affected chat.
cached timeline records or turn summaries were found for it.
Configuration corruption evidence
Extent checked
2,279,549,240 observed bytes; 126 valid JSONL files and one all-NUL file.
valid files; only the affected chat references a corrupted file. No missing
referenced files were found. Windows extended-path prefixes were normalized.
of those IDs remains in the current index; no additional disappeared indexed
chats were detected between those snapshots and the current state.
these checks cannot detect chats removed before all available snapshots.
Related reports
Related Windows zero-filled config failure signature. This occurrence also
includes permanently lost chat content on a newer installed Desktop build.
Empty-rollout resume failure, but reported temporary materialization races
should be distinguished from this persistent, nonzero-length all-NUL file.
Requested investigation
flush/sync behavior, replacement durability, and preservation of older data.
and clearly show failures to persist their contents.
copy, and how users or support can retrieve it after local transcript loss.
corruption and recovery options rather than only calling the rollout empty.
Local mitigation
Verified versioned backups now run through Windows Task Scheduler hourly and
at sign-in, outside the Codex home directory. Originals and recovery candidates
were preserved; the damaged chat was not overwritten with fabricated metadata.
Privacy
This report omits chat content, chat titles, thread IDs, account identifiers,
credentials, raw databases/logs, and private absolute paths. Private audit
files and complete backups should not be uploaded to a public issue.
SunGang-pine commentedon Oct 17, 2026
Still happening on Windows after a sudden power loss (Oct 2026).
config.toml:1:23260: key with no value, expected '='~/.codex/config.tomlcorrupted (NUL-filled) after hard power cutconfig.toml, relaunch; app regenerates defaultsPlease prioritize atomic write + flush on Windows, and auto-fallback when
config.tomlis unparseable/NUL-filled so users aren’t stuck behind a manual rename.UrosVel97 commentedon Oct 24, 2026
Additional recurrence on Windows, observed on 24 October 2026. Reporting with the affected user's explicit authorization. The same installation has repeatedly required configuration recovery and restoration of local project visibility.
Environment
Confirmed corruption and impact
config.tomlis 3,972 bytes long; all 3,972 bytes are NUL (0x00). A separately preserved older configuration backup is also entirely NUL-filled (4,555 bytes)..codex-global-state.jsonand its adjacent backup, and a configuration load failure forconfig.toml.PRAGMA quick_check = ok, and project/root records plus the relevant thread-to-project links were intact.Observed timeline on 24 October (UTC+02:00)
The user reports initiating restarts through Start menu > Restart, not intentionally cutting power. The logs nevertheless indicate an incomplete shutdown in this incident. We have not captured the process or filesystem operation that zeroed these files, and the timeline does not prove updater causation.
Recovery/persistence observations
The running desktop overwrites external edits to its in-memory project registry, so recovery required fully closing the app before restoring the relevant metadata. After reopening, the three restored projects and nine associations were verified through desktop APIs.
Inspection of the installed desktop bundle indicates that the global-state primary and adjacent backup can both be written from the same new state. When both startup copies are unreadable, subsequent persistence can therefore leave both copies without the former registry. This deserves review as a recovery/durability issue; it does not identify the original corrupting writer. The TOML app-server writer is a separate path.
Related project/sidebar recovery issue: #53251.
Causality limits
There is independent Windows instability on this machine: a 23 October kernel crash dump contains a confirmed one-bit instruction mismatch against the matching Microsoft image. This could be a contributing factor, but neither a defective RAM module nor a causal link to every Codex corruption event has been established. That dump does not show shutdown in progress. We are not claiming Codex caused the Windows crash, or that all affected users have a hardware fault.
Requested product improvements
Please investigate durable configuration/global-state writes and preservation of a last-known-good copy; validate and quarantine NUL-filled state on startup; and provide a supported recovery/reconciliation path that preserves local projects, chat membership and plugin registrations after a bad state file. Repeated resets currently require substantial manual reconstruction.
Only this sanitized summary is being shared. No raw logs, configuration contents, memory dumps, account identifiers, project names/paths, chat IDs or conversation contents are attached.
sergiobm14 commentedon Oct 28, 2026
Confirmed additional occurrence — Windows, October 28, 2026
I experienced a completely NUL-filled
config.tomlwith Codex Desktop on Windows. This report records the observed corruption and recovery; it does not establish which process or operation caused the corruption.Symptoms
Codex could not load its configuration. The reported parser error was:
VS Code identified the file as binary or using unsupported encoding, and Notepad did not show readable configuration text.
Verified byte-level evidence
The preserved copy of the affected configuration was read with PowerShell using
[System.IO.File]::ReadAllBytes, then every byte equal to zero was counted:This confirms that the entire preserved file contains
0x00, rather than merely a malformed TOML setting or an editor display problem. The reported parser column, 7138, is one position beyond the 7137-byte file.Recovery observed
config.tomlpath.Previous conversations and projects appear intact; this is a user-visible observation, not an exhaustive integrity audit. Regenerating the configuration does not establish that all previous preferences or integrations were restored.
Limits and requested investigation
The original cause and exact time of corruption remain unknown. No unexpected shutdown has been confirmed for this occurrence. I do not have a reliable reproduction sequence, and the affected app version and Windows build were not captured in this diagnosis.
Please investigate crash durability across configuration write paths, including temporary-file replacement and explicit flush/sync behavior, preserve a last-known-good validated backup, and provide an actionable startup recovery path for NUL-filled or otherwise unparseable configuration. These are investigation requests, not a claim that a particular write implementation caused this case.
The corrupted copy is preserved locally. No configuration files, raw logs, credentials, account identifiers, project details, or private absolute paths are attached or included.
MAR-Toledo commentedon Oct 28, 2026
Additional confirmed occurrence — Windows laptop battery depletion (October 28, 2026)
I would like to contribute another occurrence of this issue, including byte-level verification of the corrupted configuration file.
Environment
%USERPROFILE%\.codex\config.tomlTimeline and symptoms
config.toml:1:4012: key with no value, expected '='.codexfolder or its configuration files.Forensic verification using PowerShell
I preserved the original corrupted file by renaming it to
config.toml.bak.I then examined its contents using
Format-Hexand[System.IO.File]::ReadAllBytes().Confirmed results:
This confirms that the file was completely zero-filled, rather than simply containing an invalid TOML setting.
Recovery
config.tomltoconfig.toml.bak.Suspected trigger
The problem appeared immediately after the laptop lost power because its battery was depleted while the application was running.
This timing strongly suggests a possible connection between an unexpected shutdown and configuration corruption. However, the exact underlying cause has not been independently established.
Suggested improvement
Please investigate configuration-file durability during unexpected shutdowns and consider implementing automatic recovery from a valid backup when
config.tomlcontains only NUL bytes or cannot be parsed.This would prevent users from being locked out of the desktop application after an unexpected power interruption.
I hope this additional evidence helps the investigation.
4245877 commentedon Nov 10, 2026
Additional confirmed Windows incident (2026-11-10), with log timestamps that may help locate the config persistence failure. This appears to match this issue and #34126.
Environment
26.1021.22027-win32-x64; CLI0.164.0-alpha.11.10.167.0-alpha.3.2%USERPROFILE%\.codex\config.toml(username redacted)Observed evidence
config/batchWriterequests.config.tomlfile modification time was 12:42:36.0x00, with 0 CR and 0 LF.config.toml:1:3780: key with no value, expected '='(position 3780 = 3779 + 1). The VS Code CLIcodex login statusexited with code 1 before recovery.Recovery / verification
tomllibparsed it successfully.codex login status->Logged in using ChatGPT(exit code 0);codex mcp listalso returned successfully.codex login status->Logged in using ChatGPT(exit code 0).Request
Please investigate the
config/batchWritepersistence path on Windows, ensure crash-safe writes (including durable backup/atomic replacement where applicable), and provide an actionable recovery path for a corrupt/NUL-filledconfig.toml. The current failure can cause both clients to reject their shared config and can permanently lose user customization.No auth tokens, full logs, account identifiers, or unredacted local paths are included here.