continuedev/continue · error · Error

No edit snippet provided.

Error message

No edit snippet provided.

What it means

Relace's edit/completion API requires a user message containing the code snippet to edit; chatCompletionStream throws when no message with role 'user' (or one with empty content) exists in body.messages.

Source

Thrown at packages/openai-adapters/src/apis/Relace.ts:101

  // to Relace's format
  async *chatCompletionStream(
    body: ChatCompletionCreateParamsStreaming,
    signal: AbortSignal,
  ): AsyncGenerator<ChatCompletionChunk> {
    const headers = {
      "Content-Type": "application/json",
      Authorization: `Bearer ${this.config.apiKey}`,
    };

    const prediction = body.prediction?.content ?? "";
    const initialCode =
      typeof prediction === "string"
        ? prediction
        : prediction.map((p) => p.text).join("");

    const userContent = body.messages.find((m) => m.role === "user")?.content;
    if (!userContent) {
      throw new Error("No edit snippet provided.");
    }

    const editSnippet =
      typeof userContent === "string"
        ? userContent
        : userContent
            .filter((p) => p.type === "text")
            .map((p) => p.text)
            .join("");

    const data = {
      initialCode,
      editSnippet,
    };

    const url = this.apiBase + "code/apply";
    const response = await customFetch(this.config.requestOptions)(url, {
      method: "POST",

View on GitHub (pinned to 5522c6f44c)

Solutions

  1. Ensure body.messages includes at least one message with role:'user' whose content is a non-empty string or non-empty content parts
  2. Put the code-to-edit snippet directly in the user message content
  3. If content is an array, verify the joined parts produce non-empty text

Example fix

// before
messages: [{ role: 'system', content: 'Fix this code' }, { role: 'user', content: '' }]
// after
messages: [{ role: 'system', content: 'Fix this code' }, { role: 'user', content: 'function add(a, b) { return a - b; }' }]
Defensive patterns

Strategy: validation

Validate before calling

const hasUserContent = (m: ChatCompletionCreateParamsStreaming) => m.messages.some(msg => msg.role === 'user' && (typeof msg.content === 'string' ? msg.content.trim() : Array.isArray(msg.content) && msg.content.some(p => p.text?.trim())));

Type guard

const hasNonEmptyUserMessage = (b: { messages: any[] }): boolean => b.messages.some(m => m.role === 'user' && (typeof m.content === 'string' ? m.content.length > 0 : Array.isArray(m.content) && m.content.length > 0));

Try / catch

try { ... } catch (e) { if (e.message === 'No edit snippet provided.') throw new UserError('Provide the code to edit in a user message'); throw e; }

Prevention

When it happens

Trigger: Calling chatCompletionNonStream/chatCompletionStream (Relace) with messages that contain only system/assistant roles, or a user message whose content is empty.

Common situations: Prompt templates that put instructions in the system message and expect the code in a separate field; multi-turn histories where the last user turn was stripped; malformed content arrays where every part is empty.

Understand the failure class

Background: Missing required parameter errors: what 'X is required' and 'the required X param is missing' mean, and how to fix them — this error's family across 27 libraries.

Related errors


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