continuedev/continue · error · ContinueError

MultiEditEditsArrayEmpty

MultiEditEditsArrayEmpty

Error message

edits array must contain at least one edit

What it means

Thrown by validateMultiEdit when the edits array exists but has zero elements. An empty multi-edit is rejected as a likely caller mistake since it would be a guaranteed no-op.

Source

Thrown at core/edit/searchAndReplace/multiEditValidation.ts:31

} {
  if (typeof args !== "object" || !args || !("edits" in args)) {
    throw new ContinueError(
      ContinueErrorReason.MultiEditEditsArrayRequired,
      "invalid multi-edit args",
    );
  }

  // Validate that edits is a non-empty array
  if (!Array.isArray(args.edits)) {
    throw new ContinueError(
      ContinueErrorReason.MultiEditEditsArrayRequired,
      "edits array is required",
    );
  }
  const { edits } = args;

  if (edits.length === 0) {
    throw new ContinueError(
      ContinueErrorReason.MultiEditEditsArrayEmpty,
      "edits array must contain at least one edit",
    );
  }

  // Validate each individual edit
  for (let i = 0; i < edits.length; i++) {
    const edit = edits[i];

    // Use existing single edit validation
    validateSingleEdit(edit.old_string, edit.new_string, edit.replace_all, i);

    // Only the first edit can have empty old_string (for insertion at beginning)
    if (i > 0 && edit.old_string === "") {
      throw new ContinueError(
        ContinueErrorReason.FindAndReplaceNonFirstEmptyOldString,
        `Edit at index ${i}: old_string cannot be empty. Only the first edit can have an empty old_string for insertion at the beginning of the file.`,
      );

View on GitHub (pinned to 5522c6f44c)

Solutions

  1. Skip the multi-edit call entirely when the computed edits array is empty
  2. Guard with a conditional: if (edits.length > 0) await multiEdit({ edits })
  3. If using an LLM tool schema, tell the model to omit the call rather than send empty edits

Example fix

// before
await multiEdit({ edits: edits.filter(wanted) }); // filter may yield []
// after
const wantedEdits = edits.filter(wanted);
if (wantedEdits.length > 0) await multiEdit({ edits: wantedEdits });
Defensive patterns

Strategy: validation

Validate before calling

if (!Array.isArray(edits) || edits.length === 0) return; // skip call

Type guard

const hasEdits = (e: unknown[]): e is [unknown, ...unknown[]] => e.length > 0;

Prevention

When it happens

Trigger: Calling multi-edit with { edits: [] }, often because a filter/map chain upstream produced an empty array.

Common situations: Pipeline code that builds edits conditionally and ends up with none; LLM agents emitting an empty edits list when they decide no change is needed.

Related errors


AI-assisted analysis of continuedev/continue@5522c6f44c (2026-08-27). Data as JSON: /api/errors/181742073305df5d. Report an issue: GitHub.