Log errors return from AI GW on direct_access_endpoint
What does this MR do and why?
Log errors return from AI GW on direct_access_endpoint
Addressing: #547431 (closed)
This is a follow up MR to !193484 (merged). See this thread for more context.
In the previous MR were reporting the raised errors from the client. But with this MR we are also reporting the returned status_code and detail error message if it's found.
How to set up and validate locally
A. Returning direct access code is still working as expected
curl -i --request POST \
--header "Authorization: Bearer <YOUR_GITLAB_ACCESS_TOKEN> \
--url "http://gdk.test:3000/api/v4/code_suggestions/direct_access"
should return response as expected.
B. When error is returned, we can find the reported status code and detail error in the logs
- Comment out this line
ee/lib/gitlab/llm/ai_gateway/code_suggestions_client.rb: 87to not to send headers to the AI GW. Just as an example of a scenario to cause an error. We still don't know yet what's causing the503errors. In case the line number changes, we want to comment out this lineheaders: Gitlab::AiGateway.headers(user: user, service: service),. - In the rails app directory, run
tail -f log/exceptions_json.log|jq . - In a different shell, run this command
curl -i --request POST \
--header "Authorization: Bearer <YOUR_GITLAB_ACCESS_TOKEN> \
--url "http://gdk.test:3000/api/v4/code_suggestions/direct_access"
In the tail command you should see something like:
"extra.ai_gateway_code": 400,
"extra.ai_gateway_detail": "Missing X-Gitlab-Global-User-Id header"
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Related to #547431 (closed)