From 290b552b1110b9e091d0c7084a729fa5deb4aa51 Mon Sep 17 00:00:00 2001 From: kerry Date: Fri, 2 Oct 2026 23:11:57 +0000 Subject: [PATCH] test(spend): key-scoped guardrail block evidence without call-id header Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- tests/integration/spend/test_spend_log_request_tags.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/integration/spend/test_spend_log_request_tags.py b/tests/integration/spend/test_spend_log_request_tags.py index 0c8ab3a6817..1180f065d48 100644 --- a/tests/integration/spend/test_spend_log_request_tags.py +++ b/tests/integration/spend/test_spend_log_request_tags.py @@ -982,21 +982,21 @@ def test_guardrail_mode_tag_decider_is_unchanged_on_pass_through(gateway: Gatewa ) assert control.status_code != 200, control.text assert len(wire.drain()) == 0, "tag-matched guardrail should have blocked before the upstream" - call_id: Final = control.headers["x-litellm-call-id"] + digest: Final = sha256(key.encode()).hexdigest() def blocked_rows() -> list[dict]: return read_rows( - 'SELECT metadata FROM "LiteLLM_SpendLogs" WHERE litellm_call_id=%s', - (call_id,), + 'SELECT metadata, litellm_call_id FROM "LiteLLM_SpendLogs" WHERE api_key=%s', + (digest,), ) spend_row: Final = eventually( blocked_rows, - lambda rows: len(rows) == 1 and "bananablock" in json.dumps(rows[0]["metadata"]), + lambda rows: any("bananablock" in json.dumps(row["metadata"]) for row in rows), seconds=30, return_last_on_timeout=True, ) - if not (len(spend_row) == 1 and "bananablock" in json.dumps(spend_row[0]["metadata"])): + if not any("bananablock" in json.dumps(row["metadata"]) for row in spend_row): log_text: Final = owned.log.read_text() assert "Content blocked: keyword 'bananablock' detected" in log_text, ( "guardrail block text not in spend row or proxy log"