Skip to content

Windows Codex desktop: project registry lost after recurring NUL-byte corruption #60541

Open

Description

@growmachines

What version of the Codex App are you using (From “About Codex” dialog)?

Version 26.1103.60933

What subscription do you have?

Codex desktop on Windows 11. The installed package inspected after the second incident was OpenAI.Codex_26.1103.7773.0_x64.

What platform is your computer?

Microsoft Windows NT 10.0.26200.0 x64

What issue are you seeing?

Twice, after an unclean Windows restart, my local projects disappeared from the Codex Projects sidebar while existing conversations remained visible under Recents.

Timeline (SAST, UTC+02:00):

  • 23 October 2026: Windows logged Kernel-Power Event 41 at 07:39:07. Codex logged NUL-byte JSON parse failures at 07:39:57.
  • 10 November 2026: Windows logged Kernel-Power Event 41 at 08:12:28. Codex logged the same parse failures at 08:22:00.

Representative error excerpt:
[global-state] Failed to load global state
SyntaxError: Unexpected token '\u0000' ... is not valid JSON

After the second incident, the desktop registry contained only 1 of the 17 expected project registrations. The SQLite database still contained all 1,391 pre-incident chat IDs. Restoring the missing registrations and their original project ID mappings recovered the sidebar without editing SQLite or chat history.

Inspection of the installed desktop code showed that the app replaces .codex-global-state.json and its .bak sequentially using temporary writes and renames, with no explicit flush before replacement. If both files fail to parse, the app starts with an empty global state. An interrupted write is a plausible explanation, but the actual failing write was not captured.

Expected: preserve a separately validated last-known-good registry, flush and validate new state before replacing it, and show a recovery error if neither copy can be read rather than silently starting with empty state.

What steps can reproduce the bug?

Observed sequence; I do not have a deterministic reproduction:

  1. Use Codex desktop on Windows with existing local projects and conversations.
  2. Windows restarts unexpectedly. This occurred naturally on two occasions; I did not deliberately interrupt power or force a crash.
  3. Reopen Codex. The Projects sidebar loses its local registrations, but existing conversations remain visible under Recents.
  4. Check the desktop startup logs for [global-state] Failed to load global state with a \u0000 JSON parse error.

This is a local startup and persistence issue. No specific prompt, session ID, token limit, or context-window size is known to trigger it.

Suggested engineering test: use a disposable Windows profile and inject interruptions at each temporary write, flush, and rename boundary. On restart, verify that the last valid registry, original project IDs, and chat associations survive.

What is the expected behavior?

After an unexpected Windows restart, Codex should retain existing project registrations, original project IDs, and chat associations.

If the primary registry is unreadable, Codex should recover from a validated last-known-good copy. If no valid copy is available, it should preserve the damaged files and show a clear recovery message instead of silently starting with an empty or incomplete registry.

Additional information

About Codex version: 26.1103.60933.
Installed Windows package version inspected after the second incident: 26.1103.7773.0.

Both incidents followed an unclean restart. An interrupted write is a plausible explanation, but the failing write was not captured and the issue has not been reproduced under controlled conditions.

Suggested fix: flush and validate new state before replacing the registry, and retain a separately verified last-known-good copy. Redacted desktop log excerpts and Windows event details are available on request.

Activity

  1. added
    appIssues related to the Codex desktop app
    on Nov 10, 2026
  2. added
    bugSomething isn't working
    windows-osIssues related to Codex on Windows systems
    sessionIssues involving session (thread) management, resuming, forking, naming, archiving
    on Nov 10, 2026
  3. growmachines commented on Nov 10, 2026

    @growmachines
    Author

    The problem was caused by a power faileure.

  4. LuminairPrime commented on Nov 20, 2026

    @LuminairPrime

    Bug report from the agent that repaired my Codex install after a power outage broke the projects:

    Windows build 26.1117.3838.0 still shows an empty project list after both global-state JSON reads fail

    I’m Astra 6.2 xhigh, the Codex agent that investigated this installation. The user reported that Windows shut down abruptly during a power outage on November 20, 2026. I also reviewed an October recovery on the same PC with the same visible symptom. The evidence below is from the November incident.

    Environment. ChatGPT desktop in Codex mode, Windows 11 Pro 25H2 x64 (26200.9974), OpenAI.Codex package 26.1117.3838.0, desktop build 29513, bundled codex-cli 0.171.0-alpha.13.

    What I observed. Windows recorded Kernel-Power event 41 at 17:21:39 UTC and unexpected-shutdown event 6008 at 17:22:05. At 17:26:35.203 and 17:26:35.206, Desktop logged [global-state] Failed to load global state. Both errors reported an unexpected \u0000 at the start of the JSON input. The two stack traces correspond to the primary and backup reads in the installed loader.

    At 17:26:37.488, the same launch logged Local app-server project migration completed projectCount=15. A later launch logged 15 again. When I queried the running desktop app before repair, it returned zero local projects. The local-projects object in .codex-global-state.json was empty. I found all 15 project records in state_5.sqlite. Twelve belonged in the sidebar. The other three were empty duplicates retained after the October merge.

    What I recovered. SQLite still had project IDs for 75 main chats. For 29 more, I inferred the assignment by matching the original session folder to a project root. I couldn’t establish when those 29 database fields became null. I wrote and tested an offline repair, and the user ran it with Desktop closed. After relaunch, the app listed all 12 intended projects. I verified that all 104 saved sidebar assignments agreed with SQLite, including 11 archived chats. The repair also filled 71 helper-record memberships. SQLite’s PRAGMA integrity_check returned ok.

    There is one remaining discrepancy. The desktop history-list API returned the matching project ID for 48 of those chats, a null ID for 55, and omitted one. I verified all 104 stored assignments, but I did not inspect every chat in the rendered sidebar.

    Where I’d investigate. This build reads .codex-global-state.json, tries .codex-global-state.json.bak on failure, and returns an empty map if both reads fail. Its save path serializes the current state once and writes that payload to each file in succession using a temporary file and rename. That refreshes both copies to the same generation. I found no explicit flush to durable storage in that path. The logs establish that both reads failed. The exact sequence that put NUL bytes on disk remains unknown.

    Suggested regression test. In a disposable Windows profile, create two chats with known project assignments and one intentionally projectless chat. Leave the SQLite records intact, put a leading NUL in both global-state JSON files, and relaunch. I’d expect Desktop to recover the known assignments or offer recovery before saving an empty sidebar, while keeping the projectless chat projectless. A separate interruption test between the primary and backup replacements would check whether a previous valid generation survives power loss.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    appIssues related to the Codex desktop appbugSomething isn't workingsessionIssues involving session (thread) management, resuming, forking, naming, archivingwindows-osIssues related to Codex on Windows systems

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions