Baoyuantop commented on code in PR #14006:
URL: https://github.com/apache/apisix/pull/14006#discussion_r4284521678


##########
apisix/plugins/ai-prompt-guard.lua:
##########
@@ -160,7 +160,7 @@ function _M.access(conf, ctx)
         messages = new_messages
     end
     if #messages == 0 then --nothing to check
-        return 200
+        return

Review Comment:
   Embedding arrays bypass prompt protection
   
   An embeddings request with array input now reaches upstream without 
ai-prompt-guard checking its text. get_messages produces no messages for 
arrays, so configured deny patterns never run.



##########
t/plugin/ai-prompt-guard.t:
##########
@@ -1038,3 +1041,17 @@ POST /v1/responses
 --- response_body
 {"message":"Request contains prohibited content"}
 --- error_code: 400
+
+=== TEST 45: embeddings array input passes through when there are no messages 
to check
+--- request
+POST /hello
+{
+    "model": "text-embedding-3-small",
+    "input": [
+        "hello",
+        "world"
+    ]
+}
+--- error_code: 200
+--- response_body
+hello world

Review Comment:
   Test suite exceeds the split threshold
   
   The added coverage extends a 1,040-line test file beyond the roughly 
800-line split threshold in test style guidance. Consider moving coverage into 
a second test file.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to