Skip to content

test(integration): cover guardrails_policies endpoint contracts - #44722

Merged
mateo-berri merged 12 commits into
mainfrom
litellm_endpoint_contracts_guardrails_policies
Oct 14, 2026
Merged

mateo-berri merged 12 commits into
mainfrom
litellm_endpoint_contracts_guardrails_policies

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

TLDR

Problem this solves:

  • No integration test drove the policy routes or policy attachments over HTTP
  • Request-body policies stripping before the provider was never asserted, streaming or not
  • Encryption at rest for guardrails created through the API had no integration proof
  • The team guardrail approval gate and apply_guardrail block, alias and metadata behavior were untested

How it solves it:

  • New tests run a real proxy against owned guardrail and provider wire doubles
  • They assert the exact upstream bodies, response headers, read routes and Postgres rows
  • Every live test was proven by a one-line mutation under litellm/, then reverted
  • Test-only change, nothing under litellm/ or enterprise/ is modified

User Flow

Before: an admin attaches a policy or a team submits a guardrail, and nothing pins what happens to live traffic

  1. An admin sends POST /policies, then POST /policies/attachments with models: [M]
  2. Chat traffic on M may or may not run the guardrail until the next DB sync, and every route still returns 200
  3. A team member registers a guardrail, and nothing proves it stays inactive until an admin approves it

After: each of these flows is pinned by an integration test that reads what the upstream, the guardrail and Postgres actually received

  1. The same attachment applies on the very next chat call to M, streaming or not, scoped by model, team wildcard, key wildcard, tag (from request metadata.tags, the x-litellm-tags header, top-level tags, the key or the team) or *, two matching attachments both apply in explicit priority order, leaves model N untouched, and a blocking guardrail stops the call before the provider. A default: true attachment applies only when no other attachment matches
  2. "policies": ["p"] sent through the OpenAI SDK extra_body, streaming or not, and a published policy_<id> after a resync, run the policy's guardrail, set x-litellm-applied-policies, and never reach the provider body
  3. A pending or rejected team guardrail returns 404 on /apply_guardrail and never runs on chat, and a non-admin that reaches the approve or reject handler gets 403 and leaves the row pending_review

Coverage

A policy attachment created through POST /policies/attachments goes live on the serving worker without a restart, and the test checks the attachment readback and the LiteLLM_PolicyAttachmentTable row for each scope spelling, including tags matched from request metadata.tags, the x-litellm-tags header and top-level tags, from a key created with metadata.tags, and from a team created with metadata.tags with no request tags, and default: true. When a global attachment and a model attachment both match, both guardrails get the prompt and x-litellm-applied-policies lists both policies in explicit priority order, checked with the priorities in both directions, while another model gets only the global policy. The streaming spelling (stream=True through the OpenAI SDK) is covered for a model attachment and for request-body policies: the guardrail gets the prompt, the streamed response carries x-litellm-applied-policies, and the provider body is exactly model, messages, stream and stream_options with no policies key. When the attached guardrail replies BLOCKED the client gets a 400 naming the reason and the provider receives nothing. A generic_guardrail_api guardrail created through POST /guardrails stores its api_key encrypted, comes back masked from /guardrails/{id} and /guardrails/{id}/info, is absent from /v2/guardrails/list, and reaches only the guardrail's x-api-key header. Team guardrail submissions stay inactive until an admin approves them, stay inactive after rejection, are listed only to their own team, and fall back to the key's team when team_id is omitted. A team admin or internal user whose key is scoped to /guardrails/submissions reaches the handler and gets 403 Admin access required on approve and reject, with the row still pending_review, and the same team admin and member with plain keys are refused on all four actions with one of exactly two whole parsed bodies: today's 401 Only proxy admin route-check error naming the route, role and masked user id, or the intended 403 Admin access required, so the fix for the BUG below does not break this live test. Both apply_guardrail aliases mask identically for the master key as Authorization: Bearer and x-litellm-api-key, the long alias serves a key_type: llm_api key through apply_guardrail_routes with the same analyzer and anonymizer bodies, and both return 401 without a key. A blocking guardrail returns a 400 that names the block. Request metadata reaches a custom-code guardrail exactly, and request messages reach an Akto guardrail's payload exactly

Line numbers are at 83d2447bf8, except the rows marked (new), which are at 258f613c45

Gap Test node Mutation Assertion it tripped
guardrails_policies-1 tests/integration/management/test_policy_attachment_runtime.py::test_policy_attachments_match_live_models_teams_keys_and_global_scope[models], [teams], [keys], [*] attachment_registry.py: self.add_attachment(attachment) -> pass line 460, x-litellm-applied-policies was None
guardrails_policies-1 (streaming) ...::test_streaming_chat_on_an_attached_model_runs_the_policy_guardrail attachment_registry.py: delete self.add_attachment(attachment) line 1080, the streamed response had no x-litellm-applied-policies
guardrails_policies-1 (block) ...::test_policy_attachment_with_a_blocking_guardrail_stops_the_request_before_the_provider attachment_registry.py: self.add_attachment(attachment) -> pass line 769, blocked.status_code == 400 got 200 and the request reached the provider
guardrails_policies-1 (request tags) ...::test_policy_attachment_tag_scope_matches_only_tagged_requests policy_matcher.py:87: if scope_tags: -> if False: line 852, the untagged chat carried x-litellm-applied-policies: <policy>
guardrails_policies-1 (new, two matches) ...::test_matching_model_and_global_attachments_apply_by_priority[model-priority-first], [global-priority-first] callback_utils.py:505: ",".join(_metadata["applied_policies"]) -> ",".join(_metadata["applied_policies"][:1]) line 614, the header named only the first policy
guardrails_policies-1 (new, priority order) same nodes attachment_registry.py _attachment_sort_key: return (0, attachment.priority, *specificity) -> return (0, -attachment.priority, *specificity) line 614, the header listed both policies in reverse order
guardrails_policies-1 (new, header tags) ...::test_policy_attachment_tag_scope_matches_only_tagged_requests[header], which sends x-litellm-tags: unmatched-<hex>, <prefix>-prod so only the second tag matches litellm_pre_call_utils.py:1893: tags = [tag.strip() for tag in _tags] -> tags = [_tags[0].strip()] alone line 996, the tagged chat had no x-litellm-applied-policies
guardrails_policies-1 (new, top-level tags) ...[top_level_tags], which now also reads the spend row and asserts its caller tags exactly litellm_pre_call_utils.py:1897: if "tags" in data and isinstance(data["tags"], list): -> if False: alone line 1009, the spend row's caller tags were [] instead of [<prefix>-prod]
guardrails_policies-1 (top-level tags, equivalent) ...[top_level_tags] http_parsing_utils.py:658: request_body.get("tags", []) -> [] alone stays green equivalent here: line 1897 already copied the top-level tags into metadata.tags, which the policy match and the spend row both read
guardrails_policies-1 (pre-auth header parse, redundant) ...[header] litellm_pre_call_utils.py:1973: if not raw_header_tags: -> if True: alone stays green redundant for policies: the post-auth parse at line 1893 rebuilds metadata.tags from the header, as the line 1893 mutant shows by turning the test red on its own. The pre-auth copy only feeds the tag budget check before auth, which is outside this area
guardrails_policies-1 (new, all tag spellings) ...[metadata_tags], [header], [top_level_tags] litellm_pre_call_utils.py: all_tags: Final = get_tags_from_request_body(data) or None -> all_tags: Final = None line 989 in all three, no x-litellm-applied-policies
guardrails_policies-1 (key tags) ...::test_policy_attachment_tag_scope_matches_tags_from_the_key_and_team litellm_pre_call_utils.py:1750: tags_to_add=key_metadata["tags"], -> tags_to_add=None, line 1018, the tagged key's chat had no x-litellm-applied-policies
guardrails_policies-1 (team tags) same node litellm_pre_call_utils.py:1799: tags_to_add=team_tags if isinstance(team_tags, list) else None, -> tags_to_add=None, line 1020, the tagged team's chat had no x-litellm-applied-policies
guardrails_policies-1 (default) ...::test_default_policy_attachment_applies_only_when_no_other_attachment_matches attachment_registry.py:165: non_default or tuple(attachment for attachment in in_scope if attachment.default), -> in_scope, line 947, the M2 header was default,scoped instead of scoped
guardrails_policies-2 ...::test_request_policy_name_selects_its_production_guardrail_and_is_removed_from_provider_body, ...::test_request_published_policy_version_id_resolves_after_force_sync litellm_pre_call_utils.py: data.pop("policies", None) -> data.get("policies") _assert_provider_request line 256, provider body carried "policies"
guardrails_policies-2 (streaming) ...::test_streaming_request_body_policies_run_the_guardrail_and_are_removed_from_the_provider_body same _assert_streaming_provider_request line 355 via line 1130, provider body carried "policies"
guardrails_policies-2 (version id, no resync) ...::test_request_policy_version_id_selects_its_published_guardrail (BUG skip) none, red on main with the skip removed the chat returned 200 with no guardrail call and no x-litellm-applied-policies
guardrails_policies-3 tests/integration/security/test_stored_config_slots.py::test_api_created_guardrail_api_key_is_encrypted_at_rest_and_reaches_only_the_guardrail[success], [provider_4xx] guardrail_registry.py: safe_dumps(encrypt_guardrail_litellm_params(litellm_params_dict)) -> safe_dumps(litellm_params_dict) _assert_stored_without_canary line 176, Slot E1 stored in plaintext
guardrails_policies-4 tests/integration/authorization/test_guardrail_submissions.py::test_team_guardrail_submissions_require_admin_approval registry_read_through.py: delete "status": "active", line 379, pending submission apply returned 200, expected 404
guardrails_policies-5 tests/integration/authorization/test_guardrail_submissions.py::test_non_admin_keys_scoped_to_the_submission_routes_get_403_from_the_admin_check guardrail_endpoints.py: delete raise HTTPException(status_code=403, detail="Admin access required") in approve_guardrail_submission line 124, statuses (200, 403, 400, 403), the team admin self-approved
guardrails_policies-5 (reject) same node same raise deleted in reject_guardrail_submission line 124, statuses (403, 200, 403, 400)
guardrails_policies-5 (new, plain keys) tests/integration/authorization/test_guardrail_submissions.py::test_non_admin_keys_scoped_to_the_submission_routes_get_403_from_the_admin_check two-layer: _types.py add "/guardrails/submissions/{guardrail_id}/approve", to the non-admin allowed routes and guardrail_endpoints.py delete raise HTTPException(status_code=403, detail="Admin access required") in approve_guardrail_submission line 334, the plain team-admin approve returned 200 {"status":"active","message":"Guardrail approved"}
guardrails_policies-5 (new, plain keys, mixed refusal) same node _types.py line above only line 334, statuses (403, 401, 403, 401), approve and reject refused by different layers
guardrails_policies-5 (team admin, internal user) ...test_guardrail_submissions.py::test_team_admins_and_internal_users_get_403_on_guardrail_submission_actions (BUG skip) none, red on main with the skip removed line 124, all four actions got 401 Only proxy admin instead of 403
guardrails_policies-6 tests/integration/observability/test_presidio_entity_masking.py::test_long_apply_guardrail_alias_accepts_an_llm_api_scoped_key _types.py: remove "/guardrails/apply_guardrail", from apply_guardrail_routes line 120, both auth spellings got 403 Virtual key is not allowed to call this route
guardrails_policies-6 (short alias) ...test_presidio_entity_masking.py::test_apply_guardrail_aliases_accept_admin_auth guardrail_endpoints.py: delete @router.post("/apply_guardrail", response_model=ApplyGuardrailResponse) line 249, (404, 401) == (401, 401)
guardrails_policies-6 (x-litellm-api-key) same node user_api_key_auth.py:832: isinstance(custom_litellm_key_header, str) -> isinstance(custom_litellm_key_header, bytes) line 264, statuses (200, 200, 401, 401)
guardrails_policies-6 (llm_api key, short alias) ...::test_short_apply_guardrail_alias_accepts_an_llm_api_scoped_key (BUG skip) none, red on main with the skip removed line 120, both auth spellings got 403 on /apply_guardrail
guardrails_policies-6 (internal user) ...::test_apply_guardrail_aliases_accept_internal_user_auth (BUG skip) none, red on main with the skip removed 401 Only proxy admin on both aliases
guardrails_policies-6 (language, entities) ...::test_apply_guardrail_forwards_documented_language_and_entities_to_presidio (BUG skip) none, red on main with the skip removed line 231, the analyzer got {"text": ..., "language": "en"} with no entities
guardrails_policies-7 tests/integration/observability/test_apply_guardrail_endpoint.py::test_apply_guardrail_returns_a_block_error_for_generic_guardrails guardrail_endpoints.py: raise handle_exception_on_proxy(e) -> return ApplyGuardrailResponse(response_text=request.text) line 154, 200 == 400 with the original text returned
guardrails_policies-8 ...test_apply_guardrail_endpoint.py::test_apply_guardrail_forwards_metadata_to_custom_code guardrail_endpoints.py: **({"metadata": request.metadata} if request.metadata is not None else {}), -> **({}), line 247, metadata arrived as {}
guardrails_policies-8 (messages) ...test_apply_guardrail_endpoint.py::test_apply_guardrail_forwards_messages_to_the_guardrail guardrail_endpoints.py:2429: **({"messages": request.messages} if request.messages is not None else {}), -> **({}), line 227, Akto got only the text as a user message

Screenshots / Proof of Fix

This PR only adds tests and has no before or after product behavior. The proof is the rig runs below plus the mutation table. Every run used Postgres, Redis 7, the owned upstream and two directly addressed proxies (gateway and peer) as CircleCI starts them, with real provider credentials stripped from the environment

  1. management with tests/integration/management/test_policy_attachment_runtime.py tests/integration/authorization/test_guardrail_submissions.py: run 1 and run 2 each 14 passed, 2 skipped at 440d846a20
  2. extensions with tests/integration/observability/test_presidio_entity_masking.py tests/integration/observability/test_apply_guardrail_endpoint.py: run 1 and run 2 each 8 passed, 3 skipped at 440d846a20
  3. security with tests/integration/security/test_stored_config_slots.py: run 1 20 passed in 882.30s, run 2 20 passed in 837.53s at 89f5ab31d0, the file is unchanged since
  4. 70ecc1475f only drops an unused helper, an f-prefix and a duplicated SDK call; the two streaming tests and the llm_api alias test reran green on it and make check passed there
  5. 83d2447bf8 adds plain team-admin and member keys to the route-scoped submission test, and the row stays pending_review
  6. 4077f2c221 adds the two-match priority test and runs the tag test over all three request spellings. 258f613c45 makes the plain-key refusal accept exactly the current 401 body or the intended 403 body. management with the two files above: run 1 and run 2 each 18 passed, 2 skipped at both commits, and make check passed at both
  7. At 4077f2c221 each of the five BUG skips was removed, run once and restored, and each is still red with the symptom in its skip message: the short alias 403 Virtual key is not allowed to call this route (presidio line 120), internal-user 401 Only proxy admin on both aliases (line 385), the analyzer missing the documented entities (line 230), team admin and internal user 401 instead of 403 on approve and reject (submissions line 367), and the just-published version id with no guardrail and no header (policy runtime line 765)
  8. 7971c244e9 merges origin/main because documentation and code-quality failed on DEFER_PYDANTIC_BUILD, an env var main reads in litellm/constants.py without documenting it, in files this PR does not touch
  9. 030d0e3b78 sends two comma-separated header tags with the match second and pins the spend row's caller tags for every spelling. management with the two files above: run 1 and run 2 each 18 passed, 2 skipped, and make check passed
  10. 3e77f92998 merges origin/main again and 42c7ba6ae1 drops the duplicate pydantic import that merge left. management with the two files above: 18 passed, 2 skipped at 42c7ba6ae1

Type

Test

Caveats (if any)

Medium

Five product bugs on main are pinned as BUG skips that assert the intended contract, so those halves of gaps 2, 5 and 6 and the language/entities spelling stay partial until the product fixes land, and each was reconfirmed red at 4077f2c221. Non-admin virtual keys get 401 on both apply_guardrail aliases, because apply_guardrail_routes sits in llm_api_routes but is_llm_api_route never reads it. A key_type: llm_api key is served on /guardrails/apply_guardrail but refused with 403 on /apply_guardrail, since only the long alias is listed. Team admins and internal users get 401 from the route check instead of the documented 403 on submission approve and reject; the handler's own 403 is pinned by the route-scoped key test, and the current plain-key 401 is pinned exactly next to it so either layer moving is caught. A just-published policy version id applies no guardrail until a DB resync, so the hard version-id test calls force_sync=true first. /guardrails/apply_guardrail drops the documented language and entities fields before Presidio

Low

The streaming provider body includes stream_options: {"include_usage": true}, which the proxy adds for usage accounting; the test pins it because it is a documented OpenAI parameter the provider must accept. The messages half of gap 8 is proven through an Akto guardrail, since the custom-code guardrail hides messages from its code. The API-created guardrail test reuses the existing E1 canary slot, because a new slot would need an edit under _support/. osv-scan fails on lockfiles identical to main, unrelated to this diff


Note

Low Risk
Test-only changes under tests/integration/; production behavior is unchanged, though skipped tests document existing auth and policy-sync bugs on main.

Overview
Adds integration tests only (no litellm/ changes) that drive the proxy against wire doubles and assert upstream bodies, response headers, Postgres rows, and auth outcomes for guardrails and policies.

Policy attachments and request policies: New coverage in test_policy_attachment_runtime.py checks that attachments take effect on the next chat (including streaming), match model/team/key/tag/global/default scopes, order multiple matches by priority, strip policies before the provider, run blocking guardrails before upstream, and resolve published policy_<version_id> after force_sync. One test is skipped for a known resync bug.

Team guardrail submissions: test_guardrail_submissions.py pins pending/rejected guardrails as inactive on chat and /apply_guardrail, admin approve/reject flows, team-scoped listing, and non-admin 403 (or current 401) on submission actions, with a skip for team-admin 401 vs documented 403.

Apply guardrail and storage: test_apply_guardrail_endpoint.py covers generic BLOCKED → 400, Akto messages forwarding, and custom-code metadata. Presidio tests gain alias/auth cases (plus BUG skips for short alias, internal users, and language/entities). test_stored_config_slots.py adds a case that API-created guardrail api_key is encrypted at rest, masked on read, and sent only to the guardrail upstream.

Reviewed by Cursor Bugbot for commit 7971c24. Bugbot is set up for automated code reviews on this repo. Configure here.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

@greptile-apps

greptile-apps Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Low risk] Adds integration tests for guardrails and policy endpoints.

The PR appears safe to merge; the previous blocking test assertion now permits the intended authorization response.

Findings

  1. P1 Test requires incorrect 401 ▶
  2. P2 Priority execution goes unchecked ▶

Summary

The PR adds integration coverage for policy attachments, guardrail approvals, apply_guardrail behavior, and API-created guardrail secret storage. Since the previous review, it changes the plain-key authorization assertion to accept either the current uniform 401 response or the intended uniform 403 response.

Reviews (7) · Last reviewed commit: "Merge remote-tracking branch 'origin/mai..."

@codecov

codecov Bot commented Oct 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@mateo-berri

Copy link
Copy Markdown
Contributor

@greptileai

@mateo-berri

Copy link
Copy Markdown
Contributor

bugbot run

@cursor cursor Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@mateo-berri

Copy link
Copy Markdown
Contributor

@greptileai

@mateo-berri

Copy link
Copy Markdown
Contributor

bugbot run

@cursor cursor Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

mateo-berri and others added 2 commits October 6, 2026 04:35
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ mateo-berri
❌ Devin


Devin seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@mateo-berri

Copy link
Copy Markdown
Contributor

@greptileai

@mateo-berri

Copy link
Copy Markdown
Contributor

@greptileai

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@mateo-berri

Copy link
Copy Markdown
Contributor

@greptileai

Comment on lines +307 to +332
assert tuple(response.status_code for response in plain_responses) == (401, 401, 401, 401), tuple(
response.text for response in plain_responses
)
expected_routes: Final = tuple(
f"/guardrails/submissions/{guardrail_id}/{action}" for action in ("approve", "reject", "approve", "reject")
)
expected_user_ids: Final = (team_admin, team_admin, member, member)
expected_plain_errors: Final = tuple(
_ErrorResponse(
error=_ProxyError(
message=(
"Authentication Error, Only proxy admin can be used to generate, delete, update info for "
f"new keys/users/teams. Route={route}. Your role=internal_user. "
f"Your user_id={_mask_user_id(user_id)}"
),
type="auth_error",
param="None",
code="401",
)
)
for route, user_id in zip(expected_routes, expected_user_ids, strict=True)
)
parsed_plain_errors: Final = tuple(
_ErrorResponse.model_validate_json(response.content) for response in plain_responses
)
assert parsed_plain_errors == expected_plain_errors, tuple(response.text for response in plain_responses)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Test requires incorrect 401

For plain team-admin and member keys, this test now requires the route check’s 401 response and exact error text. The adjacent skipped test says these approve/reject requests should return 403. When authorization is fixed to return that intended 403, this live test will fail and block the fix.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 258f613: plain keys now pass on either the current route-layer 401 body or the intended handler 403, and the BUG skip keeps the 403 contract

Comment on lines +614 to +620
assert matched.headers.get("x-litellm-applied-policies") == ",".join(expected_order), matched.text
matched_model_guardrail_requests: Final = model_guardrail.drain()
matched_global_guardrail_requests: Final = global_guardrail.drain()
assert len(matched_model_guardrail_requests) == 1
assert len(matched_global_guardrail_requests) == 1
_assert_guardrail_request(matched_model_guardrail_requests[0], _PROMPT, model, key, response=matched)
_assert_guardrail_request(matched_global_guardrail_requests[0], _PROMPT, model, key, response=matched)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Priority execution goes unchecked

The header shows policy order, but it is recorded separately from guardrail execution. Both guardrails return NONE, and draining each server only shows that it ran once. The test could therefore pass if the guardrails run in the wrong priority order, leaving that part of the contract unprotected.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Execution order is not a contract here: policy_resolver.py unions every matched policy guardrail into a set, so priority only orders the applied-policy list this header pins

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You’re right — thanks for the clarification. Since policy_resolver.py unions matched guardrails into a set, execution order is not part of the contract; priority only determines the x-litellm-applied-policies ordering, which this test already verifies. The separate drains correctly assert that each matched guardrail ran, so this is not a valid finding.

mateo-berri and others added 2 commits October 6, 2026 07:53
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@mateo-berri

Copy link
Copy Markdown
Contributor

@greptileai

@mateo-berri mateo-berri added run-ci and removed run-ci labels Oct 6, 2026
@mateo-berri

Copy link
Copy Markdown
Contributor

bugbot run

@cursor cursor Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

@mateo-berri mateo-berri removed the run-ci label Oct 6, 2026
… tag scope

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@mateo-berri

Copy link
Copy Markdown
Contributor

@litereview code-review

@mateo-berri

Copy link
Copy Markdown
Contributor

bugbot run

@cursor cursor Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

@litereview

litereview Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

✅ code-review

5/5 · Ready for human review

Scope: full · Full PR review.

Completed · Some checks not run.

No correctness findings.

This PR only adds integration tests under tests/integration/. All five files live in directories that GROUPS in tests/integration/run.py selects (management, authorization, observability, security). The known product bugs follow the pytest.skip("BUG: &lt;symptom>") convention from tests/integration/AGENTS.md. No supported API, config, or persisted data changes.

Checks and execution details
  • Passed · Real testing evidence (required): Not applicable: no LLM translation changes in the scoped paths. The diff touches only tests/integration/authorization/test_guardrail_submissions.py, tests/integration/management/test_policy_attachment_runtime.py, tests/integration/observability/test_apply_guardrail_endpoint.py, tests/integration/observability/test_presidio_entity_masking.py and tests/integration/security/test_stored_config_slots.py. Nothing under litellm/llms/** or litellm/litellm_core_utils/prompt_templates/** changes.
  • Passed · Syntax compile of changed test files (optional): python3 -m py_compile succeeded for all five changed files on Python 3.12.1.
  • Passed · Integration suite placement and conventions (optional): Every changed directory appears in GROUPS in tests/integration/run.py: management, authorization and configuration run under management, observability runs under extensions, and security has its own entry. The BUG skips sit at the top of each test body, as tests/integration/AGENTS.md requires. The new litellm.types.guardrails import follows the existing practice of importing litellm from integration tests, for example in authorization/test_auth_object_prefetch.py.
  • Not run · Live integration run (Postgres + Redis + proxy) (optional): The sandbox has no Postgres, Redis or Docker, so I did not run the new suites. The PR reports two clean management runs (18 passed, 2 skipped) and mutation checks for each live test. I did not verify those reported runs myself.

View review · Reviewed 42c7ba6ae158

mateo-berri and others added 2 commits October 14, 2026 03:39
…n merge

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@mateo-berri

Copy link
Copy Markdown
Contributor

@litereview code-review

@mateo-berri

Copy link
Copy Markdown
Contributor

bugbot run

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 42c7ba6. Configure here.

@mateo-berri mateo-berri left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mateo-berri
mateo-berri merged commit 02f56c6 into main Oct 14, 2026
86 of 87 checks passed
@mateo-berri
mateo-berri deleted the litellm_endpoint_contracts_guardrails_policies branch October 14, 2026 04:07
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.

2 participants