{"record":{"id":"873cf0db968e177d","repo":"continuedev/continue","slug":"no-edit-snippet-provided","errorCode":null,"errorMessage":"No edit snippet provided.","messagePattern":"No edit snippet provided\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/openai-adapters/src/apis/Relace.ts","lineNumber":101,"sourceCode":"  // to Relace's format\n  async *chatCompletionStream(\n    body: ChatCompletionCreateParamsStreaming,\n    signal: AbortSignal,\n  ): AsyncGenerator<ChatCompletionChunk> {\n    const headers = {\n      \"Content-Type\": \"application/json\",\n      Authorization: `Bearer ${this.config.apiKey}`,\n    };\n\n    const prediction = body.prediction?.content ?? \"\";\n    const initialCode =\n      typeof prediction === \"string\"\n        ? prediction\n        : prediction.map((p) => p.text).join(\"\");\n\n    const userContent = body.messages.find((m) => m.role === \"user\")?.content;\n    if (!userContent) {\n      throw new Error(\"No edit snippet provided.\");\n    }\n\n    const editSnippet =\n      typeof userContent === \"string\"\n        ? userContent\n        : userContent\n            .filter((p) => p.type === \"text\")\n            .map((p) => p.text)\n            .join(\"\");\n\n    const data = {\n      initialCode,\n      editSnippet,\n    };\n\n    const url = this.apiBase + \"code/apply\";\n    const response = await customFetch(this.config.requestOptions)(url, {\n      method: \"POST\",","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/continuedev/continue/blob/5522c6f44ca0ac3528b37244818fbfa39b5af470/packages/openai-adapters/src/apis/Relace.ts#L83-L119","documentation":"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.","triggerScenarios":"Calling chatCompletionNonStream/chatCompletionStream (Relace) with messages that contain only system/assistant roles, or a user message whose content is empty.","commonSituations":"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.","solutions":["Ensure body.messages includes at least one message with role:'user' whose content is a non-empty string or non-empty content parts","Put the code-to-edit snippet directly in the user message content","If content is an array, verify the joined parts produce non-empty text"],"exampleFix":"// before\nmessages: [{ role: 'system', content: 'Fix this code' }, { role: 'user', content: '' }]\n// after\nmessages: [{ role: 'system', content: 'Fix this code' }, { role: 'user', content: 'function add(a, b) { return a - b; }' }]","handlingStrategy":"validation","validationCode":"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())));","typeGuard":"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));","tryCatchPattern":"try { ... } catch (e) { if (e.message === 'No edit snippet provided.') throw new UserError('Provide the code to edit in a user message'); throw e; }","preventionTips":["Always include the target code in the user message","Validate message roles before sending to Relace"],"tags":["relace","validation","chat-messages","edit"],"backgroundTag":"missing-required-parameter","analyzedSha":"5522c6f44ca0ac3528b37244818fbfa39b5af470","analyzedAt":"2026-08-27T11:28:54.683Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}