fix(bedrock): guardrail config dropped on retry - #7087
Draft
kohlivrinda wants to merge 1 commit into
Draft
Conversation
Contributor
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: trueComment |
kohlivrinda
force-pushed
the
09-11-fix_bedrock_guardrail_config_dropped_on_retry
branch
from
September 11, 2026 13:26
75bf5cf to
1b30c06
Compare
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
When
applyBedrockExtraParamspromotes keys likeguardrailConfigto typed fields on the Bedrock request, it deletes those keys from the map. Because the converter was aliasingbifrostReq.Params.ExtraParamsdirectly rather than copying it, those deletes mutated the caller's original request. Since core re-runs the converter on every retry and fallback attempt against the sameBifrostChatRequest, any subsequent attempt saw noguardrailConfigand reached Bedrock silently unguarded — with no error raised anywhere.Changes
convertChatParametersinutils.gonow clonesbifrostReq.Params.ExtraParamsviamaps.Clonebefore assigning it tobedrockReq.ExtraParams, preventingapplyBedrockExtraParamsfrom mutating the caller's map.ToBedrockResponsesRequestinresponses.goapplies the same clone for the same reason, since it also deletes keys (e.g.stop) from the extra params map.TestGuardrailConfigSurvivesReconversionis added covering both the chat completion and responses paths, asserting that the caller'sExtraParamsmap is untouched after conversion and that a simulated retry produces a request with the guardrail still attached.Type of change
Affected areas
How to test
go test ./core/providers/bedrock/... -run TestGuardrailConfigSurvivesReconversion -vThe test simulates two consecutive conversions of the same
BifrostChatRequestandBifrostResponsesRequest(as core does on retry), asserting thatguardrailConfigis present on both the first and second converted requests, and that the originalExtraParamsmap is not modified.Screenshots/Recordings
N/A
Breaking changes
Related issues
N/A
Security considerations
Without this fix, guardrails configured via
guardrailConfiginExtraParamswere silently dropped on any retry or fallback attempt, meaning requests could reach Bedrock without the intended guardrail applied. This fix ensures guardrails are consistently enforced across all attempts.Checklist
docs/contributing/README.mdand followed the guidelines