apply_patch keeps writing literal “+” into files when patch context contains inline “+” (editing error risk)

Resolved 💬 2 comments Opened Mar 16, 2026 by ArisAachen Closed Mar 16, 2026

What version of Codex CLI is running?

codex-cli 0.114.0

What subscription do you have?

ChatGPT Plus

Which model were you using?

gpt-5.4 xhigh

What platform is your computer?

Linux 6.19.8-arch1-1 x86_64 GNU/Linux

What terminal emulator and version are you using (if applicable)?

macos warp

What issue are you seeing?

While editing send.ts with apply_patch, I repeatedly ended up with literal + characters embedded in the file content (e.g., const A...+const B... and return [];+ }). This happens when a patch hunk includes +
in the same physical line as other code (likely from concatenated diff context). apply_patch treats the entire line as literal content, so the + gets written into the file instead of acting as a diff marker.
This makes it easy to corrupt code when multiple edits are applied sequentially.

What steps can reproduce the bug?

Repeated edits can accumulate stray + characters inside code blocks, breaking compilation and requiring manual cleanup. This happened multiple times even when the patch itself looked valid.
Suggested improvement:
Add validation to detect suspicious inline + sequences like ; +const or } + in added lines, or enforce stricter formatting of patch hunks so accidental concatenation is caught.

``` js
const TEAM_MANAGER_ACCOUNT_ID = "team_manager";+const TASK_NOTIFY_DEDUPE_MS = 10 * 60_000;+const TASK_ID_RE = /\bT-[A-Za-z0-9_-]{3,}\b/;+const recentTaskNotifies = new Map<string, number>();+
function extractMentions(message: string): string[] {
if (!message || !message.includes("@")) {
return [];+ }
const mentions: string[] = [];+ const re = /@([\p{L}\p{N}._-]+)/gu;+ let match: RegExpExecArray | null;+ while ((match = re.exec(message)) !== null) {
const mention = match[1]?.trim();+ if (mention) {
mentions.push(mention);+ }
}
return mentions;+}

function resolveTaskId(message: string): string | null {
const match = message.match(TASK_ID_RE);+ return match ? match[0] : null;+}


### What is the expected behavior?

apply_patch should only interpret leading + / - as diff markers, and should not silently accept inline + that appear as accidental concatenation artifacts in patch context. At minimum, it should warn or reject
  patches that introduce inline + adjacent to code when that + is not part of the intended content.

### Additional information

_No response_

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗