test(guardrails): pin monitor mode against provider failures - #746
Conversation
enforcement_mode=monitor promises 'observe, never intercept', but every existing monitor test exercised only content flags on the in-process keyword/pii guardrails. The interaction reported in AISIX-Cloud#1010 — a remote moderation provider erroring/timing out under monitor mode — had no coverage at any level, even though it takes a different path (provider failure -> fail_open verdict -> decorator stack) than a content flag. Adds: - e2e: aliyun_text_moderation against a hard-down mock endpoint — block+fail_open=false fails closed (422), flipping the same guardrail to monitor lets traffic flow again (while still consulting the provider), and a flag-everything provider is observed-not-blocked. - unit: build_one composition — monitor downgrades a fail-closed provider-failure Block; mandatory (applied outermost, documented in build_one) keeps provider unavailability fatal in monitor mode. Ref api7/AISIX-Cloud#1010
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 7 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
… align test 3 title with its assertions
What
Regression coverage for the
enforcement_mode: "monitor"contract under provider failure, prompted by AISIX-Cloud#1010 (monitor-mode Aliyun guardrail reported intermittently returning 422).Verified against current
main(identical guardrail code to v0.3.1): the behavior is already correct — monitor mode downgrades every block, including a fail-closed provider outage. What was missing is any test pinning that interaction; existing monitor tests only covered content flags on in-process guardrails (keyword/pii), never a failing remote provider.Tests added
e2e (
guardrail-monitor-provider-failure-e2e.test.ts, realaisix+ etcd + mock green-cip endpoint):block+fail_open: false+ hard-down moderation endpoint → 422content_filter(the only guardrail-path mechanism that can produce the symptom reported in the issue; doubles as the propagation gate)monitor→ traffic flows again, upstream reached, provider still consultedmonitor+ a flag-everything provider → observed, not blockedunit (
build.rs, composed throughbuild_oneso the decorator ordering itself is pinned):Blockmandatory: truekeeps provider unavailability fatal in monitor mode (the documented outermost-decorator exception)Notes
Fixes— root cause in the reported environment is still being confirmed on the issue; these tests pin the current-code contract).🤖 Generated with Claude Code