Skip to content

The apply_diff tool must validate separator order to prevent file corruption #1557

@KJ7LNW

Description

@KJ7LNW

Which version of the app are you using?

3.8.4

Which API Provider are you using?

Anthropic

Which Model are you using?

sonnet-3.5

What happened?

The apply_diff tool currently allows incorrect ordering of separators in diff blocks which could lead to file corruption. The example shows a diff block with multiple ======= separators and incorrect ordering

Steps to reproduce

This will depend on model response so there is not a reproducer, but it would be simple to write some test cases and make sure the implementation handles hey meaningful response to the model.

Relevant API REQUEST output

<<<<<<< SEARCH
:start_line:47
:end_line:52
-------
		if (!terminalInfo) {
			console.error("[TerminalRegistry] Shell execution ended but process is undefined for terminal:", {
				terminalId: terminalInfo?.id,
				exitCode: e?.exitCode
			})
			return
=======
		if (!terminalInfo) {
			console.error("[TerminalRegistry] Shell execution ended but terminal not found:", {
				exitCode: e?.exitCode
			})
			return
=======

<<<<<<< SEARCH
:start_line:64
:end_line:69
-------
		const exitDetails = TerminalProcess.interpretExitCode(e?.exitCode)
		console.info("[TerminalRegistry] Shell execution ended:", {
			...exitDetails,
			terminalId: terminalInfo?.id,
			command: process.command
		})
=======
		const exitDetails = TerminalProcess.interpretExitCode(e?.exitCode)
		console.info("[TerminalRegistry] Shell execution ended:", {
			...exitDetails,
			terminalId: terminalInfo.id,
			command: process?.command || '<unknown>'
		})
>>>>>>> REPLACE

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue - Needs ScopingValid, but needs effort estimate or design input before work can start.bugSomething isn't working

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions