Fix incorrect customer portal URL reference
What does this merge request do and why?
This fixes an incorrect customer portal URL reference that causes breakages of self-managed authentications to AI Gateway. This bug was introduced as part of !561 (merged)!
https://log.gprd.gitlab.net/app/r/s/d5jDB
This impact all self-managed users as they are unable to use the Code Suggestions feature.
Steps to reproduce
- Check out the main branch
- Ensure a local Docker image built successfully.
docker buildx build --platform linux/amd64 \ -t ai-gateway:dev .
- Run a local service on Docker with auth enabled and staging customer dot URL
docker run --platform linux/amd64 --rm \ -p 5052:5052 \ -e AIGW_AUTH__BYPASS_EXTERNAL=false \ -e AIGW_GITLAB_URL="http://gdk.test:8080/" \ -e AIGW_GITLAB_API_URL="http://gdk.test:8080/api/v4/" \ -e AIGW_CUSTOMER_PORTAL_BASE_URL=https://customers.staging.gitlab.com -v $PWD:/app -it ai-gateway:dev
- Execute the follow cURL command
curl --request POST \ --url http://codesuggestions.gdk.test:5999/v2/completions \ --header 'Content-Type: application/json' \ --header 'X-Gitlab-Authentication-Type: oidc' \ --data '{ "prompt_version": 1, "project_path": "awesome_project", "project_id": 23, "current_file": { "file_name": "hello.go", "content_above_cursor": "func (h* HotelHandler) HandleGetHotels(c *fiber.Ctx) error {\n\thotels, err := h.Store.Hotels.GetHotels(c.Context(), nil)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn", "content_below_cursor": "\n}" } }'
- Observe the error in the log
{ "status_code": null, "backtrace": "Traceback (most recent call last):\n File \"/app/ai_gateway/auth/providers.py\", line 99, in _fetch_well_known\n res = requests.get(url=url, timeout=REQUEST_TIMEOUT_SECONDS)\n File \"/opt/venv/ai-gateway-9TtSrW0h-py3.10/lib/python3.10/site-packages/requests/api.py\", line 73, in get\n return request(\"get\", url, params=params, **kwargs)\n File \"/opt/venv/ai-gateway-9TtSrW0h-py3.10/lib/python3.10/site-packages/requests/api.py\", line 59, in request\n return session.request(method=method, url=url, **kwargs)\n File \"/opt/venv/ai-gateway-9TtSrW0h-py3.10/lib/python3.10/site-packages/requests/sessions.py\", line 575, in request\n prep = self.prepare_request(req)\n File \"/opt/venv/ai-gateway-9TtSrW0h-py3.10/lib/python3.10/site-packages/requests/sessions.py\", line 486, in prepare_request\n p.prepare(\n File \"/opt/venv/ai-gateway-9TtSrW0h-py3.10/lib/python3.10/site-packages/requests/models.py\", line 368, in prepare\n self.prepare_url(url, params)\n File \"/opt/venv/ai-gateway-9TtSrW0h-py3.10/lib/python3.10/site-packages/requests/models.py\", line 439, in prepare_url\n raise MissingSchema(\nrequests.exceptions.MissingSchema: Invalid URL '/.well-known/openid-configuration': No scheme supplied. Perhaps you meant https:///.well-known/openid-configuration?\n", "correlation_id": "69ac9a08ad9341219695b4f79cf282b9", "extra": { "oidc_provider": "CustomersDot" }, "logger": "exceptions", "level": "error", "type": "mlops", "stage": "main", "timestamp": "2024-01-09T02:41:56.316567Z", "message": "Invalid URL '/.well-known/openid-configuration': No scheme supplied. Perhaps you meant https:///.well-known/openid-configuration?" }
How to set up and validate locally
- Check out to this merge request's branch.
- Ensure a local Docker image built successfully.
docker buildx build --platform linux/amd64 \ -t ai-gateway:dev .
- Run a local service on Docker with auth enabled and staging customer dot URL
docker run --platform linux/amd64 --rm \ -p 5052:5052 \ -e AIGW_AUTH__BYPASS_EXTERNAL=false \ -e AIGW_GITLAB_URL="http://gdk.test:8080/" \ -e AIGW_GITLAB_API_URL="http://gdk.test:8080/api/v4/" \ -e AIGW_CUSTOMER_PORTAL_BASE_URL=https://customers.staging.gitlab.com -v $PWD:/app -it ai-gateway:dev
- Execute the follow cURL command
curl --request POST \ --url http://codesuggestions.gdk.test:5999/v2/completions \ --header 'Content-Type: application/json' \ --header 'X-Gitlab-Authentication-Type: oidc' \ --data '{ "prompt_version": 1, "project_path": "awesome_project", "project_id": 23, "current_file": { "file_name": "hello.go", "content_above_cursor": "func (h* HotelHandler) HandleGetHotels(c *fiber.Ctx) error {\n\thotels, err := h.Store.Hotels.GetHotels(c.Context(), nil)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn", "content_below_cursor": "\n}" } }'
- Observe the above error does not show (user still expect to see key error since we do not use a valid key)
{ "status_code": null, "backtrace": "Traceback (most recent call last):\n File \"/app/ai_gateway/auth/providers.py\", line 99, in _fetch_well_known\n res = requests.get(url=url, timeout=REQUEST_TIMEOUT_SECONDS)\n File \"/opt/venv/ai-gateway-9TtSrW0h-py3.10/lib/python3.10/site-packages/requests/api.py\", line 73, in get\n return request(\"get\", url, params=params, **kwargs)\n File \"/opt/venv/ai-gateway-9TtSrW0h-py3.10/lib/python3.10/site-packages/requests/api.py\", line 59, in request\n return session.request(method=method, url=url, **kwargs)\n File \"/opt/venv/ai-gateway-9TtSrW0h-py3.10/lib/python3.10/site-packages/requests/sessions.py\", line 575, in request\n prep = self.prepare_request(req)\n File \"/opt/venv/ai-gateway-9TtSrW0h-py3.10/lib/python3.10/site-packages/requests/sessions.py\", line 486, in prepare_request\n p.prepare(\n File \"/opt/venv/ai-gateway-9TtSrW0h-py3.10/lib/python3.10/site-packages/requests/models.py\", line 368, in prepare\n self.prepare_url(url, params)\n File \"/opt/venv/ai-gateway-9TtSrW0h-py3.10/lib/python3.10/site-packages/requests/models.py\", line 439, in prepare_url\n raise MissingSchema(\nrequests.exceptions.MissingSchema: Invalid URL '/.well-known/openid-configuration': No scheme supplied. Perhaps you meant https:///.well-known/openid-configuration?\n", "correlation_id": "69ac9a08ad9341219695b4f79cf282b9", "extra": { "oidc_provider": "CustomersDot" }, "logger": "exceptions", "level": "error", "type": "mlops", "stage": "main", "timestamp": "2024-01-09T02:41:56.316567Z", "message": "Invalid URL '/.well-known/openid-configuration': No scheme supplied. Perhaps you meant https:///.well-known/openid-configuration?" }
Merge request checklist
-
Tests added for new functionality. If not, please raise an issue to follow up. -
Documentation added/updated, if needed.
Edited by Tan Le