{"record":{"id":"d6a1586e24099137","repo":"abhigyanpatwari/GitNexus","slug":"azure-content-filter-blocked-this-request-the-pro","errorCode":null,"errorMessage":"Azure content filter blocked this request. The prompt triggered content policy. Details: ${errorText.slice(0, 300)}","messagePattern":"Azure content filter blocked this request\\. The prompt triggered content policy\\. Details: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"gitnexus/src/core/wiki/llm-client.ts","lineNumber":437,"sourceCode":"    if (config.requestTimeoutMs !== undefined && isTimeoutLikeError(err)) {\n      throw new Error(\n        `LLM request timed out after ${formatTimeoutDuration(config.requestTimeoutMs)}. ` +\n          'Increase --timeout or omit it to disable the request timeout.',\n      );\n    }\n    throw err;\n  }\n\n  if (!response.ok) {\n    const errorText = await response.text().catch(() => 'unknown error');\n\n    // Azure content filter — surface a clear message instead of a generic API error.\n    if (\n      azure &&\n      response.status === 400 &&\n      (errorText.includes('content_filter') || errorText.includes('ResponsibleAIPolicyViolation'))\n    ) {\n      throw new Error(\n        `Azure content filter blocked this request. The prompt triggered content policy. Details: ${errorText.slice(0, 300)}`,\n      );\n    }\n\n    // Any other non-OK response here is a terminal 4xx — resilientFetch\n    // already retried 5xx/429 to exhaustion and would have thrown above.\n    throw new Error(`LLM API error (${response.status}): ${errorText.slice(0, 500)}`);\n  }\n\n  // Streaming path\n  if (useStream && response.body) {\n    return await readSSEStream(response.body, options!.onChunk!);\n  }\n\n  // Non-streaming path\n  const json = (await response.json()) as any;\n  const choice = json.choices?.[0];\n  if (!choice?.message?.content) {","sourceCodeStart":419,"sourceCodeEnd":455,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/d540b00184d71a896261ee02670da9a92d59d8f7/gitnexus/src/core/wiki/llm-client.ts#L419-L455","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Revise or sanitize the input — remove or redact the flagged content (the 300-char body slice often names the category).","Move to a non-Azure provider (OpenAI direct, OpenRouter, local) that does not apply the same filter.","Ask your Azure admin to relax the content filter on the deployment/resource (Azure portal → Content filters).","Chunk the prompt smaller so the offending segment is isolated, or skip the affected file/section."],"exampleFix":"// before\nsystemPrompt = 'Summarize this exploit code in detail: <exploit payload>';\nawait callLLM(prompt, { provider: 'azure', baseUrl, apiKey, model });\n// -> Azure content filter blocked this request...\n\n// after: redact + switch provider for sensitive sections\nawait callLLM(redact(prompt), { baseUrl: 'https://api.openai.com/v1', apiKey, model });","handlingStrategy":"validation","validationCode":"// Strip obvious policy triggers before sending:\nfunction sanitizeForAzure(text) {\n  return text.replace(/\\b(kill|exploit|hack|bomb)\\b/gi, '[redacted]');\n}\n// then send the sanitized prompt, or choose a non-Azure provider for sensitive content.","typeGuard":"function isAzureContentFilterError(e) {\n  return e instanceof Error && /Azure content filter blocked this request/.test(e.message);\n}","tryCatchPattern":"try { return await callLLM(prompt, config); }\ncatch (e) {\n  if (isAzureContentFilterError(e)) {\n    // route the chunk to a non-Azure provider, or skip/log this section\n    return await callLLM(sanitize(prompt), nonAzureConfig);\n  }\n  throw e;\n}","preventionTips":["Avoid sending raw exploit/offensive content; redact before prompt construction.","For repos with sensitive code, prefer OpenAI-direct, OpenRouter, or local providers.","Ask your Azure admin to attach a relaxed content-filter policy to the deployment."],"tags":["llm","azure","content-filter","policy","wiki"],"backgroundTag":null,"analyzedSha":"d540b00184d71a896261ee02670da9a92d59d8f7","analyzedAt":"2026-08-12T19:50:25.132Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}