Skip to content

STA-1598: Handle CRLF project headers during Codex config repair - #8197

Merged
Jinwoo-H merged 1 commit into
mainfrom
fix/STA-1598-crlf-project-dedupe
Jul 11, 2026
Merged

Jinwoo-H merged 1 commit into
mainfrom
fix/STA-1598-crlf-project-dedupe

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Jul 11, 2026 •

Copy link
Copy Markdown
Contributor

Why this follow-up exists

This fixes a regression introduced by #8138 while addressing STA-1598.

The semantic project-header parser is used from two paths with different line shapes:

  • direct trust upserts scan lines after removing the CR from CRLF input
  • the mirror uses config.split('\n'), so a CRLF section header still ends in \r

parseCodexProjectHeaderPath accepted only spaces/tabs after the closing ]. As a result, it rejected every CRLF project header supplied by the mirror. A Windows system config project section was copied as ordinary config, then the LF runtime-owned copy was appended, creating an exact duplicate table before Codex auto-started.

This was reproduced on 1.4.135-rc.1.perf: the real runtime config contained 142 duplicated project-header groups. The two copies of the reported workspace differed only by the first header's terminal 0x0D carriage return.

Fix

Strip one terminal CR before parsing a project header. This aligns mirror parsing with the existing direct-upsert scanner without changing path values, quote handling, Windows/UNC normalization, SSH behavior, or hooks-state formatting.

Regression coverage

New end-to-end mirror tests cover:

  • CRLF system project + LF runtime project collapsing to one table
  • self-healing duplicates already inside a CRLF runtime config
  • CRLF system untrusted revocation overriding LF runtime trusted

All three tests failed before the fix and pass afterward.

Evidence so far

  • focused project trust + mirror tests: 118 passed
  • Codex, Codex accounts, local trust, and remote/SSH trust suites: 419 passed, 7 skipped
  • pnpm typecheck: passed
  • pnpm check:max-lines-ratchet: passed
  • targeted oxlint/lint-staged: passed
  • copied production-shaped config replay: 142 duplicate header groups before, 0 after; real codex features list parsed the healed copy
  • Electron/CDP Windows E2E: seeded a duplicate CRLF/LF runtime config and confirmed real Codex rejected it; created a disposable repo workspace with backend Codex auto-start (startupTerminal.spawned = true); the rendered terminal showed the interactive Codex v0.144 prompt in the new workspace; afterward the seed project and new workspace each had one table, no duplicate groups remained, and codex features list exited 0 against the healed runtime

References

@coderabbitai

coderabbitai Bot commented Jul 11, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Updated Codex project header parsing to remove trailing carriage returns before processing. Added tests covering CRLF/LF interoperability, duplicate project table removal, project header deduplication, and propagation of an untrusted trust level.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR explains the fix and testing, but it omits required template sections for Screenshots, AI Review Report, Security Audit, and Notes. Rewrite the description to match the template with explicit Summary, Screenshots, Testing checklist, AI Review Report, Security Audit, and Notes sections.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The fix and tests address the duplicate project-table startup failure by healing CRLF/LF headers and honoring untrusted revocations.
Out of Scope Changes check ✅ Passed Only targeted parser and regression-test changes are present; no unrelated code paths or features appear to have been added.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title is specific and accurately summarizes the CRLF project-header parsing fix in Codex config repair.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Jinwoo-H
Jinwoo-H merged commit e6906d6 into main Jul 11, 2026
3 checks passed
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