Symptoms
- A large share of requests fail with HTTP 400 and
"code": "content_filter", message similar to "The response was filtered due to the prompt triggering Azure OpenAI's content management policy". - Or calls return 200 but
finish_reasoniscontent_filterand the answer is empty or cut off. - Inputs are normal business content: incident tickets, security logs, medical or HR text.
- Started after a change: a new or edited content filter policy, a blocklist update, a new deployment, a model version upgrade, or a new prompt template.
This is not quota or an outage. The service is working and refusing on purpose. Your job is to find which filter fired and why it started now.
1. Confirm scope and impact
Look at the error body. It names the filter category.
from openai import AzureOpenAI, BadRequestError
try:
r = client.chat.completions.create(model="gpt-4o-prod", messages=msgs)
print(r.choices[0].finish_reason)
print(r.choices[0].content_filter_results) # output-side results
print(getattr(r, "prompt_filter_results", None)) # input-side results
except BadRequestError as e:
print(e.code) # "content_filter"
print(e.body.get("innererror", {})) # code + content_filter_result
The content_filter_result shows each category with filtered and severity (or detected for jailbreak and protected material), and any custom_blocklists that matched.
| What fired | Typical cause after a change |
|---|---|
hate, violence, self_harm, sexual with filtered: true at low severity | Threshold tightened to block low severity |
jailbreak detected: true | Prompt Shields turned on; your template or user data looks like an instruction override |
indirect_attack | Prompt Shields for documents now scans retrieved RAG content |
custom_blocklists | New blocklist entry matches common words |
protected_material_text / _code | Protected material filter enabled on output |
| Only one deployment affected | That deployment uses a different policy |
Count how many requests are affected, per deployment, from your app logs. If you log the error code:
AppExceptions
| where TimeGenerated > ago(2h)
| where OuterMessage has "content_filter" or Details has "content_filter"
| summarize failures = count() by bin(TimeGenerated, 5m), tostring(Properties.deployment)
Field names depend on how your app logs; adjust to your telemetry.
2. Find what changed
Which policy each deployment uses:
RG=rg-ai; ACCT=aoai-prod
az cognitiveservices account deployment list -g $RG -n $ACCT \
--query "[].{name:name, model:properties.model.name, version:properties.model.version, rai:properties.raiPolicyName}" -o table
The policies themselves:
SUB=$(az account show --query id -o tsv)
BASE="https://management.azure.com/subscriptions/$SUB/resourceGroups/$RG/providers/Microsoft.CognitiveServices/accounts/$ACCT"
az rest --method get --url "$BASE/raiPolicies?api-version=2024-10-01" \
--query "value[].{name:name, base:properties.basePolicyName, mode:properties.mode}" -o table
az rest --method get --url "$BASE/raiPolicies/prod-filter?api-version=2024-10-01" \
--query "properties.contentFilters[].{name:name, source:source, enabled:enabled, blocking:blocking, threshold:severityThreshold}" -o table
Who changed it and when:
az monitor activity-log list -g $RG --offset 3d \
--query "[?contains(operationName.value, 'raiPolicies') || contains(operationName.value, 'raiBlocklists') || contains(operationName.value, 'deployments')].{t:eventTimestamp, op:operationName.value, who:caller, status:status.value}" -o table
If nothing changed on the Azure side, check your own deploy: a new system prompt, more retrieved chunks, or a new data source (for example raw security logs that contain attack strings) is the usual trigger for jailbreak and indirect_attack.
3. Roll back
Pick the smallest change that restores service.
Policy edited: put back the previous filter settings
Get the previous definition from IaC or Git. Re-apply it:
az rest --method put --url "$BASE/raiPolicies/prod-filter?api-version=2024-10-01" \
--body @prod-filter-previous.json
prod-filter-previous.json has the shape:
{
"properties": {
"basePolicyName": "Microsoft.DefaultV2",
"mode": "Default",
"contentFilters": [
{ "name": "Violence", "source": "Prompt", "enabled": true, "blocking": true, "severityThreshold": "Medium" },
{ "name": "Violence", "source": "Completion", "enabled": true, "blocking": true, "severityThreshold": "Medium" },
{ "name": "Jailbreak", "source": "Prompt", "enabled": true, "blocking": true }
]
}
}
Include every filter from the previous version, not just the one you are changing. Check the policy schema for your API version.
Warning
Do not "fix" a Sev1 by turning filters off. Loosening thresholds below the defaults or disabling filtering requires Microsoft approval for modified content filtering, and it removes a control your security and legal teams rely on. Go back to the last known-good settings and get sign-off for anything beyond that.
Deployment points at the wrong policy
Re-assign the previous policy name through your IaC (raiPolicyName on the deployment resource) and re-deploy. In an emergency, az rest --method put on the deployment with its full current body and the corrected raiPolicyName does the same; export the body first with az rest --method get.
Blocklist entry too broad
az rest --method get --url "$BASE/raiBlocklists/prod-terms/raiBlocklistItems?api-version=2024-10-01" \
--query "value[].{id:name, pattern:properties.pattern, regex:properties.isRegex}" -o table
az rest --method delete --url "$BASE/raiBlocklists/prod-terms/raiBlocklistItems/<item-name>?api-version=2024-10-01"
Prompt or data change triggered Prompt Shields
Roll back the app release, or for RAG content: put retrieved text inside clear delimiters, strip raw payloads (encoded strings, script blocks) that are not needed for the answer, and summarise logs before passing them in. Policy changes are not the right fix for this case.
4. Verify recovery
- Re-run the failing requests from step 1; they return 200 with
finish_reason: stop. - Failure count from your logs back to baseline.
- Run your safety test set too: known harmful prompts must still be blocked.
Tell users
"Some AI features were refusing normal requests since
Prevent it next time
- Content filter policies, blocklists and
raiPolicyNameassignments in Bicep or Terraform, changed only through a pipeline. - Test every policy change against two sets before production: real business prompts that must pass, and harmful prompts that must be blocked.
- Use annotate mode (
blocking: false) for a few days on a new filter to measure false positives before enforcing. - Alert on the rate of
content_filtererrors andfinish_reasonvalues per deployment. - Show users a clear "this request was blocked by a safety filter" message, so a spike is reported as such and not as "the AI is down".
Get the weekly HubDatAI email
One email a week with everything new: posts, learning sessions and videos. Free, no spam, unsubscribe in one click. What you get