Skip to content

Fix fail-open for grayswan and pass metadata to cygnal api endpoint - #19837

Merged
5 commits merged into
BerriAI:litellm_oss_staging_02_03_2026from
GraySwanAI:xiaohan/fail_open_fix_and_dynamic_extrabody
Feb 3, 2026
Merged

Fix fail-open for grayswan and pass metadata to cygnal api endpoint#19837
5 commits merged into
BerriAI:litellm_oss_staging_02_03_2026from
GraySwanAI:xiaohan/fail_open_fix_and_dynamic_extrabody

Conversation

@Reapor-Yurnero

@Reapor-Yurnero Reapor-Yurnero commented Jan 27, 2026

Copy link
Copy Markdown
Contributor

Relevant issues

Partially dependent on the fix on anthropic response mutation issue #19784

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have Added testing in the tests/litellm/ directory, Adding at least 1 test is a hard requirement - see details
  • My PR passes all unit tests on make test-unit
  • My PR's scope is as isolated as possible, it only solves 1 specific problem

Type

🐛 Bug Fix

Changes

  1. Fix fail-open bug for grayswan guardrail
  2. Pass metadata field in extra_body to grayswan cygnal endpoint.
  3. Pass litellm_metadata from request_data to grayswan cygnal endpoint
  4. Update Grayswan guardrail documentation from ground up.

@vercel

vercel Bot commented Jan 27, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
litellm Ready Ready Preview, Comment Feb 1, 2026 1:32am

Request Review

@ghost

ghost commented Jan 27, 2026

Copy link
Copy Markdown

@jquinter can you review this?

@ishaan-jaff ishaan-jaff 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.

reviewed

def _is_grayswan_block_exception(self, exc: HTTPException) -> bool:
detail = getattr(exc, "detail", None)
if isinstance(detail, dict):
return detail.get("error") == "Blocked by Gray Swan Guardrail"

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.

Blocked by Gray Swan Guardrai

this should be in constants.py file

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.

can grayswan guarantee this won't change ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

In global constants.py might be not the best idea? I put it as a local constant so when the error is raised when this is checked it is always going to use the same const so should be fine now.

is_output=is_output,
)
return result
except ModifyResponseException:

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.

can this section be a function itself. handle_grayswan_exception()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

optimize the exception handling to be much cleaner

@jquinter

Copy link
Copy Markdown
Contributor

Linter is not passing due a dependency issue, not directly related to your PR, but if you could change this line in pyproject.toml file, could make things a little easier. It should be around line 48.

BEFORE
python-multipart = { version = "^0.0.22", optional = true }

AFTER
python-multipart = { version = "^0.0.22", optional = true, python = ">=3.10" }

@Reapor-Yurnero

Copy link
Copy Markdown
Contributor Author

Done but it leads to conflict. will let you handle that.

@ghost

ghost commented Jan 31, 2026

Copy link
Copy Markdown

same comment - let's revert the pyproject changes - we cannot merge due to this. @jquinter noting for future - we should not ask oss contributors to make this change.

@ghost

ghost commented Jan 31, 2026

Copy link
Copy Markdown
Screenshot 2026-01-31 at 3 25 41 PM for context, this is what i see

@Reapor-Yurnero

Copy link
Copy Markdown
Contributor Author

Bumping this up thanks!

@ghost
ghost changed the base branch from main to litellm_oss_staging_02_03_2026 February 3, 2026 22:41
@ghost
ghost merged commit 2b25d03 into BerriAI:litellm_oss_staging_02_03_2026 Feb 3, 2026
6 of 8 checks passed
fzowl pushed a commit to fzowl/litellm that referenced this pull request Jun 24, 2026
…erriAI#19837)

* fix fail-open for grayswan; pass metadata to cygnal api endpoint; update docs

* pass litellm_metadata to cygnal in payload

* switch error msg to const, and clean exception handling.

* update pyproject.toml as requested

* Revert "update pyproject.toml as requested"

This reverts commit 4eece15.
This pull request was closed.
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.

3 participants