Repository navigation
fix(ai-prompt-guard): check embeddings string arrays before forwarding - #14073
Open
ruanweihong-aaa wants to merge 3 commits into
Open
ruanweihong-aaa wants to merge 3 commits into
ruanweihong-aaa wants to merge 3 commits into
Conversation
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.
Description
When
ai-prompt-guardselects no messages, it returns an empty HTTP 200without forwarding the request upstream.
PR #14006 fixes this early termination, but embeddings string arrays
still skip inspection because
get_messagesonly extracts string inputs.For example, with
deny_patterns: ["secret"], the batch{"input": ["secret", "hello"]}would be forwarded without being checked.This PR:
a batch, keeping them together so the default last-message filter
cannot discard earlier items.
This follows the fix proposed in #14006 and addresses @Baoyuantop's
comments about array inspection and splitting the test file.
Fixes #13944.
Compatibility
No configuration changes are required. String inputs and chat
role/history filtering retain their existing behavior.
Embeddings string arrays now undergo the configured allow/deny checks.
Batch strings are joined with spaces and checked together: allow
patterns apply to the combined text, and any deny-pattern match rejects
the request.
Token-ID arrays are not decoded or inspected. Recognized requests with
no selected text continue processing even with
fail_mode: "error",which applies to unrecognized protocols.
Validation
15 assertions against unmodified master.
and 11 ai-proxy cases pass.