Skip to content

test(guardrails): pin monitor mode against provider failures - #746

Merged
jarvis9443 merged 2 commits into
mainfrom
test/guardrail-monitor-provider-failure
Jul 10, 2026
Merged

test(guardrails): pin monitor mode against provider failures#746
jarvis9443 merged 2 commits into
mainfrom
test/guardrail-monitor-provider-failure

Conversation

@jarvis9443

Copy link
Copy Markdown
Contributor

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, real aisix + etcd + mock green-cip endpoint):

  1. block + fail_open: false + hard-down moderation endpoint → 422 content_filter (the only guardrail-path mechanism that can produce the symptom reported in the issue; doubles as the propagation gate)
  2. same guardrail flipped to monitor → traffic flows again, upstream reached, provider still consulted
  3. monitor + a flag-everything provider → observed, not blocked

unit (build.rs, composed through build_one so the decorator ordering itself is pinned):

  • monitor downgrades a fail-closed provider-failure Block
  • mandatory: true keeps provider unavailability fatal in monitor mode (the documented outermost-decorator exception)

Notes

  • Test-only; no behavior change.
  • Ref api7/AISIX-Cloud#1010 (intentionally not 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

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
@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 7 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 388927de-a8a0-4a03-aea2-0d08aafdf400

📥 Commits

Reviewing files that changed from the base of the PR and between 4ddd6ad and ff35817.

📒 Files selected for processing (2)
  • crates/aisix-guardrails/src/build.rs
  • tests/e2e/src/cases/guardrail-monitor-provider-failure-e2e.test.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test/guardrail-monitor-provider-failure

Comment @coderabbitai help to get the list of available commands.

@jarvis9443
jarvis9443 merged commit 05d6804 into main Jul 10, 2026
12 checks passed
@jarvis9443
jarvis9443 deleted the test/guardrail-monitor-provider-failure branch July 10, 2026 11:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant