Skip to content

fix(ai-prompt-guard): pass through when no content is selected - #14006

Open
avnijainnn wants to merge 1 commit into
apache:masterfrom
avnijainnn:fix/ai-prompt-guard-empty-pass-through
Open

avnijainnn wants to merge 1 commit into
apache:masterfrom
avnijainnn:fix/ai-prompt-guard-empty-pass-through

Conversation

@avnijainnn

Copy link
Copy Markdown

Description

ai-prompt-guard currently returns HTTP 200 when no messages are selected for checking. Since returning a status code terminates plugin processing, the request does not continue to the upstream and clients receive an empty 200 response.

This PR changes the empty-message path to use a bare return, allowing the request to continue upstream as intended.

It also adds regression coverage for:

  • a system-only request when match_all_roles is false
  • an OpenAI embeddings request with array input

The targeted ai-prompt-guard test suite passes with 175 tests.

Which issue(s) this PR fixes:

Fixes #13944

Checklist

  • I have explained the need for this PR and the problem it solves
  • I have explained the changes or the new features added to this PR
  • I have added tests corresponding to this change
  • I have updated the documentation to reflect this change
  • I have verified that this change is backward compatible (If not, please discuss on the APISIX mailing list first)

Documentation update is not required because this change only corrects the existing pass-through behavior and does not introduce any new configuration or user-facing API.

@avnijainnn

Copy link
Copy Markdown
Author

@Santoshkumarpuppala Thanks again for the pointers! I’ve opened the focused fix with the TEST 9 upstream-response assertion and the embeddings array-input regression. The targeted ai-prompt-guard suite is passing with 175 tests.

Would appreciate your review when you get a chance.

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.

bug: ai-prompt-guard returns an empty 200 instead of proxying when no content is selected for checking

1 participant