Fix doubled /v1 in Duo self-hosted endpoint probe
What does this MR do and why?
gitlab:duo:verify_self_hosted_setup appends /v1/models to a self-hosted model endpoint that the documentation requires to already end in /v1 ("The URL must be suffixed with /v1"), at verify_self_hosted_setup.rb:469 and again in the rescue branch at :494. A correctly configured model is probed at <endpoint>/v1/v1/models, gets a 404, and, on an air-gapped instance where this task is usually the administrator's only check, is reported as Model endpoint returned non-200 status.
The fix strips a trailing /v1 before appending, so http://host:8000/v1 and a bare http://host:8000 both probe http://host:8000/v1/models, and the error branch reuses that URL. Probing <endpoint>/models directly would change behaviour for endpoints configured without the suffix, so the appended segment stays. The one configuration whose probe does change is an endpoint that already ends in /v1 while its models route sits at <endpoint>/v1/models; inference calls to <endpoint>/chat/completions would not reach such a server either. !235438 (merged) narrowed this check to custom_openai identifiers and did not touch the URL construction.
I reproduced this on omnibus 19.3.0-ee with vLLM 0.27.1 serving Qwen2.5-7B-Instruct at http://<host>:8000/v1: the diagnostic JSON recorded "endpoint": "http://<host>:8000/v1/v1/models" with "http_code": 404, while http://<host>:8000/v1/models returned 200 from the same Rails process and the endpoint then served a completion. On 19.3.1-ee against an OpenAI-compatible endpoint the task again probed <endpoint>/v1/v1/models, recorded "http_code": 404 and printed the warning, while <endpoint>/v1/models returned 200 from the same process.
This change was drafted with AI assistance (Claude Code); I reviewed the diff and ran the reproductions myself.
References
Closes #581299
Endpoint contract: https://docs.gitlab.com/administration/gitlab_duo_self_hosted/supported_llm_serving_platforms/
Screenshots or screen recordings
Not applicable: a rake task with no UI.
How to set up and validate locally
- Register a self-hosted model whose
endpointends in/v1and whoseidentifierstarts withcustom_openai/. - Run
bundle exec rake gitlab:duo:verify_self_hosted_setup. Before:/v1/v1/modelsand a non-200 status in the diagnostic JSON. After:/v1/modelsand 200. bundle exec rspec ee/spec/lib/gitlab/duo/administration/verify_self_hosted_setup_spec.rb
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.