fix(guardrails): Surface 500 when guardrail result cannot be parsed - #1213
Open
JashG wants to merge 1 commit into
Open
fix(guardrails): Surface 500 when guardrail result cannot be parsed#1213JashG wants to merge 1 commit into
JashG wants to merge 1 commit into
Conversation
Signed-off-by: Jash Gulabrai <jgulabrai@nvidia.com>
Contributor
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughGuardrail middleware now rejects generation responses without activation logs with HTTP 500 errors. Block detection accepts ChangesGuardrail log handling
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Contributor
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Addresses edge case where a rail result cannot be parsed from the underlying
GenerationResponse. Previously, we blocked the request andDEBUGlogged the error. This PR updates the plugin to return an explicit500with aWARNINGlog.Changes
responses.py: Refactoredis_blocked_generation_responseto acceptGenerationLogdirectly instead ofGenerationResponse. The caller (i.e. the plugin middleware) returns early if there is noGenerationLog.middleware.py: Added alog is Noneguard in bothprocess_request(input rails) andprocess_response(output rails) that raisesInferenceMiddlewareError(status_code=500)and logs atWARNINGbefore the blocked/unblocked branch is evaluated.Type of Change
Quality Gates
Verification
Signed-off-by:traileruv run pre-commit run -apasses, or any blocked checks are identified belowTargeted validation:
uv run --frozen pytest plugins/nemo-guardrails/ -x -q412 passed, 292 warnings
Summary by CodeRabbit
Bug Fixes
Tests