abhigyanpatwari/GitNexus · error · Error

Azure content filter blocked this request. The prompt trigge

Error message

Azure content filter blocked this request. The prompt triggered content policy. Details: ${errorText.slice(0, 300)}

What it means

Azure-specific: after resilientFetch returns a response that is not OK, if the provider was detected as Azure (config.provider==='azure' or isAzureProvider(baseUrl)) AND response.status===400 AND the body contains 'content_filter' or 'ResponsibleAIPolicyViolation', GitNexus throws this clear message instead of the generic API error. Azure's content policy rejected the prompt before producing any completion.

Source

Thrown at gitnexus/src/core/wiki/llm-client.ts:437

    if (config.requestTimeoutMs !== undefined && isTimeoutLikeError(err)) {
      throw new Error(
        `LLM request timed out after ${formatTimeoutDuration(config.requestTimeoutMs)}. ` +
          'Increase --timeout or omit it to disable the request timeout.',
      );
    }
    throw err;
  }

  if (!response.ok) {
    const errorText = await response.text().catch(() => 'unknown error');

    // Azure content filter — surface a clear message instead of a generic API error.
    if (
      azure &&
      response.status === 400 &&
      (errorText.includes('content_filter') || errorText.includes('ResponsibleAIPolicyViolation'))
    ) {
      throw new Error(
        `Azure content filter blocked this request. The prompt triggered content policy. Details: ${errorText.slice(0, 300)}`,
      );
    }

    // Any other non-OK response here is a terminal 4xx — resilientFetch
    // already retried 5xx/429 to exhaustion and would have thrown above.
    throw new Error(`LLM API error (${response.status}): ${errorText.slice(0, 500)}`);
  }

  // Streaming path
  if (useStream && response.body) {
    return await readSSEStream(response.body, options!.onChunk!);
  }

  // Non-streaming path
  const json = (await response.json()) as any;
  const choice = json.choices?.[0];
  if (!choice?.message?.content) {

View on GitHub (pinned to d540b00184)

Solutions

  1. Revise or sanitize the input — remove or redact the flagged content (the 300-char body slice often names the category).
  2. Move to a non-Azure provider (OpenAI direct, OpenRouter, local) that does not apply the same filter.
  3. Ask your Azure admin to relax the content filter on the deployment/resource (Azure portal → Content filters).
  4. Chunk the prompt smaller so the offending segment is isolated, or skip the affected file/section.

Example fix

// before
systemPrompt = 'Summarize this exploit code in detail: <exploit payload>';
await callLLM(prompt, { provider: 'azure', baseUrl, apiKey, model });
// -> Azure content filter blocked this request...

// after: redact + switch provider for sensitive sections
await callLLM(redact(prompt), { baseUrl: 'https://api.openai.com/v1', apiKey, model });
Defensive patterns

Strategy: validation

Validate before calling

// Strip obvious policy triggers before sending:
function sanitizeForAzure(text) {
  return text.replace(/\b(kill|exploit|hack|bomb)\b/gi, '[redacted]');
}
// then send the sanitized prompt, or choose a non-Azure provider for sensitive content.

Type guard

function isAzureContentFilterError(e) {
  return e instanceof Error && /Azure content filter blocked this request/.test(e.message);
}

Try / catch

try { return await callLLM(prompt, config); }
catch (e) {
  if (isAzureContentFilterError(e)) {
    // route the chunk to a non-Azure provider, or skip/log this section
    return await callLLM(sanitize(prompt), nonAzureConfig);
  }
  throw e;
}

Prevention

When it happens

Trigger: Sending a prompt (system or user content) that trips Azure OpenAI's content filter: hate/sexual/violence/self-harm categories, jailbreak patterns, or sometimes sensitive source code/PII in the prompt. Status 400 with a JSON body whose error.content_filter_result or error.code indicates ResponsibleAIPolicyViolation.

Common situations: Indexing/wiking a repo that contains offensive strings or security-exploit code; prompts that quote jailbreak attempts; large prompts where one chunk happens to contain flagged tokens; strict Azure subscription with default content policy.

Related errors


AI-assisted analysis of abhigyanpatwari/GitNexus@d540b00184 (2026-08-12). Data as JSON: /api/errors/d6a1586e24099137. Report an issue: GitHub.