codex - 💡(How to fix) Fix IntelliJ integration rejects valid apply_patch move hunks with ACP parse error [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openai/codex#17635Fetched 2026-04-14 05:41:59
View on GitHub
Comments
0
Participants
1
Timeline
4
Reactions
0
Author
Participants
Timeline (top)
labeled ×3unlabeled ×1

The IntelliJ Codex integration appears to reject valid apply_patch move hunks before the tool call completes.

Standalone Codex does not show this behavior in the same workflow, so this looks specific to the IntelliJ integration path rather than the core patch format itself.

Reviewed date: 2026-04-13.

Error Message

Failed to initialize ACP process. Process terminated with exit code: 1. Process output: 53 | } 54 | else if ((/^@@/).test(line)) { 55 | index.hunks.push(parseHunk()); 56 | } 57 | else if (line) { 58 | throw new Error('Unknown line ' + (i + 1) + ' ' + JSON.stringify(line)); ^ error: Unknown line 12 "Moved to: /Users/.../LogFileQueryServiceImpl.kt" at U (node_modules/diff/libesm/patch/parse.js:58:27) at S6 (node_modules/diff/libesm/patch/parse.js:144:9) at dN (node_modules/diff/libesm/patch/apply.js:30:19) at r3 (src/CodexToolCallMapper.ts:261:24) at async sU (src/CodexToolCallMapper.ts:42:31) at async createItemEvent (src/CodexEventHandler.ts:183:30) at async createUpdateEvent (src/CodexEventHandler.ts:73:35) at async handleNotification (src/CodexEventHandler.ts:55:40)

Bun v1.3.11 (macOS arm64)

Root Cause

The IntelliJ Codex integration appears to reject valid apply_patch move hunks before the tool call completes.

Standalone Codex does not show this behavior in the same workflow, so this looks specific to the IntelliJ integration path rather than the core patch format itself.

Reviewed date: 2026-04-13.

Fix Action

Fix / Workaround

The IntelliJ Codex integration appears to reject valid apply_patch move hunks before the tool call completes.

Standalone Codex does not show this behavior in the same workflow, so this looks specific to the IntelliJ integration path rather than the core patch format itself.

When Codex in IntelliJ tries to move a file using apply_patch with the documented move header:

Code Example

*** Begin Patch
*** Update File: <old path>
*** Move to: <new path>
@@
...
*** End Patch

---

Failed to initialize ACP process. Process terminated with exit code: 1. Process output:
53 |             }
54 |             else if ((/^@@/).test(line)) {
55 |                 index.hunks.push(parseHunk());
56 |             }
57 |             else if (line) {
58 |                 throw new Error('Unknown line ' + (i + 1) + ' ' + JSON.stringify(line));
                               ^
error: Unknown line 12 "Moved to: /Users/.../LogFileQueryServiceImpl.kt"
      at U (node_modules/diff/libesm/patch/parse.js:58:27)
      at S6 (node_modules/diff/libesm/patch/parse.js:144:9)
      at dN (node_modules/diff/libesm/patch/apply.js:30:19)
      at r3 (src/CodexToolCallMapper.ts:261:24)
      at async sU (src/CodexToolCallMapper.ts:42:31)
      at async createItemEvent (src/CodexEventHandler.ts:183:30)
      at async createUpdateEvent (src/CodexEventHandler.ts:73:35)
      at async handleNotification (src/CodexEventHandler.ts:55:40)

Bun v1.3.11 (macOS arm64)
RAW_BUFFERClick to expand / collapse

Summary

The IntelliJ Codex integration appears to reject valid apply_patch move hunks before the tool call completes.

Standalone Codex does not show this behavior in the same workflow, so this looks specific to the IntelliJ integration path rather than the core patch format itself.

Reviewed date: 2026-04-13.

Problem

When Codex in IntelliJ tries to move a file using apply_patch with the documented move header:

*** Begin Patch
*** Update File: <old path>
*** Move to: <new path>
@@
...
*** End Patch

the integration fails before the move is applied and surfaces an ACP initialization / patch parse error.

Observed error:

Failed to initialize ACP process. Process terminated with exit code: 1. Process output:
53 |             }
54 |             else if ((/^@@/).test(line)) {
55 |                 index.hunks.push(parseHunk());
56 |             }
57 |             else if (line) {
58 |                 throw new Error('Unknown line ' + (i + 1) + ' ' + JSON.stringify(line));
                               ^
error: Unknown line 12 "Moved to: /Users/.../LogFileQueryServiceImpl.kt"
      at U (node_modules/diff/libesm/patch/parse.js:58:27)
      at S6 (node_modules/diff/libesm/patch/parse.js:144:9)
      at dN (node_modules/diff/libesm/patch/apply.js:30:19)
      at r3 (src/CodexToolCallMapper.ts:261:24)
      at async sU (src/CodexToolCallMapper.ts:42:31)
      at async createItemEvent (src/CodexEventHandler.ts:183:30)
      at async createUpdateEvent (src/CodexEventHandler.ts:73:35)
      at async handleNotification (src/CodexEventHandler.ts:55:40)

Bun v1.3.11 (macOS arm64)

Important detail: this occurred in the IntelliJ integration flow while moving implementation files into a dedicated package/directory. A standalone Codex instance did not exhibit the same issue.

Why It Matters

This blocks a normal refactoring operation that should be representable as a move hunk rather than a delete-and-recreate.

Practical impact:

  • file moves fail in the IDE integration,
  • the agent has to fall back to shell moves or rewrite files manually,
  • the integration behaves differently from standalone Codex,
  • users lose confidence in whether apply_patch grammar is actually supported consistently across surfaces.

Code References

Relevant stack frames from the failing integration output:

  • node_modules/diff/libesm/patch/parse.js:58
  • node_modules/diff/libesm/patch/parse.js:144
  • node_modules/diff/libesm/patch/apply.js:30
  • src/CodexToolCallMapper.ts:261
  • src/CodexToolCallMapper.ts:42
  • src/CodexEventHandler.ts:183
  • src/CodexEventHandler.ts:73
  • src/CodexEventHandler.ts:55

Proposed Fix Envelope

  • Verify that the IntelliJ integration accepts the same apply_patch move grammar as standalone Codex.
  • If the integration rewrites patch headers internally, ensure *** Move to: is preserved exactly.
  • If the ACP bridge is translating the patch into a different parser format, normalize move hunks before handing them to the parser.
  • Add an integration-level regression test specifically for a valid file move patch.

Introduction History

Not investigated beyond the current failing integration behavior. The main observed fact is that the bug reproduces in IntelliJ integration but not in standalone Codex.

Suggested Test Scenarios

  • Regression scenario: submit an apply_patch payload containing *** Update File: plus *** Move to: and confirm the move succeeds in the IntelliJ integration.
  • Control scenario: submit a normal non-move update hunk and confirm patch application still succeeds.
  • Cross-surface scenario: run the same move patch through standalone Codex and IntelliJ integration and assert consistent behavior.
  • Error-shape scenario: if the patch is actually malformed, surface a grammar-specific validation error rather than an ACP initialization failure.

extent analysis

TL;DR

The issue can be resolved by ensuring the IntelliJ integration preserves the *** Move to: header in apply_patch move hunks and normalizes move hunks before parsing.

Guidance

  • Verify that the IntelliJ integration accepts the same apply_patch move grammar as standalone Codex, specifically checking for the preservation of the *** Move to: header.
  • Check if the ACP bridge is translating the patch into a different parser format and ensure move hunks are normalized before being handed to the parser.
  • Implement an integration-level regression test for a valid file move patch to catch similar issues in the future.
  • Review the patch parsing logic in node_modules/diff/libesm/patch/parse.js to understand how it handles *** Move to: headers.

Example

No code snippet is provided as the issue seems to be related to the integration and parsing of patch headers rather than a specific code block.

Notes

The issue appears to be specific to the IntelliJ integration and not a problem with the core patch format itself, as standalone Codex does not exhibit the same behavior. Ensuring consistent behavior across surfaces (standalone Codex and IntelliJ integration) is crucial for user confidence in the apply_patch grammar.

Recommendation

Apply a workaround by modifying the IntelliJ integration to preserve the *** Move to: header in apply_patch move hunks and normalize move hunks before parsing, as this is likely to resolve the issue without waiting for a potential fix in the underlying libraries or core Codex functionality.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING