aibrix icon indicating copy to clipboard operation
aibrix copied to clipboard

Wrong api-key results in 500 response but not 401

Open Jeffwan opened this issue 10 months ago • 0 comments

🐛 Describe the bug

I0214 00:36:27.428639       1 gateway.go:219] "-- In RequestHeaders processing ..." requestID="38630cf2-358f-4401-b663-9e9271082dd1"
I0214 00:36:27.428828       1 gateway.go:284] "-- In RequestBody processing ..." requestID="38630cf2-358f-4401-b663-9e9271082dd1"
I0214 00:36:27.428855       1 gateway.go:355] "request start" requestID="38630cf2-358f-4401-b663-9e9271082dd1" model="llama2-7b"
I0214 00:36:27.430141       1 gateway.go:404] "-- In ResponseHeaders processing ..." requestID="38630cf2-358f-4401-b663-9e9271082dd1"
I0214 00:36:27.430313       1 gateway.go:436] "-- In ResponseBody processing ..." requestID="38630cf2-358f-4401-b663-9e9271082dd1"
E0214 00:36:27.430444       1 gateway.go:490] "unexpected response" requestID="38630cf2-358f-4401-b663-9e9271082dd1" responseBody=<
	{"error":"Unauthorized"}
 >

this should be 401 but in the code base we

Steps to Reproduce

use a wrong apiKey and hit the gateway service

curl -v "http://localhost:8888/v1/chat/completions" \
  -H "Content-Type: application/json" -H "Authorization: Bearer test-key-1234567890a" -H "routing-strategy: least-kv-cache" \
  -d '{
     "model": "llama2-7b",
     "messages": [{"role": "user", "content": "Say this is a test!"}],
     "temperature": 0.7
   }'

Expected behavior

  1. whatever error codes returned by gateway should be returned to end users. gateway should not convert the error codes
  2. it should return the error messages as well for debug purpose.

Environment

  • AIBrix versions: nightly

Jeffwan avatar Feb 14 '25 01:02 Jeffwan