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
- 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.
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
- 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.
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
- LLM returned empty response
- Insecure http:// LLM base URLs are only allowed for localhos
- LLM endpoint circuit open: retry in ${Math.ceil(err.retryAft
- LLM API error (${err.response.status} after retries): ${erro
- LLM request timed out after ${formatTimeoutDuration(config.r
AI-assisted analysis of abhigyanpatwari/GitNexus@d540b00184 (2026-08-12).
Data as JSON: /api/errors/d6a1586e24099137.
Report an issue: GitHub.