Fix Duo Agentic Chat for self-manged instances using a relative URL
What does this MR do and why?
Fixes Duo agentic chat failing in the web UI when GitLab is served under a relative URL (eg. https://example.com/gitlab).
On these instances, sending a chat msg fails with Not found "api/graphql". The reason is in Workhorse, when DWS (duo workflow service) uses Workhorse to make a GitLab api call, it sends a bare path like "/api/graphql". But Workhorse feeds that back into its own router which only recognizes paths that include the instance's URL prefix (eg. /gitlab). The prefix is missing, so chat breaks.
This MR prepends relative URL root to the DWS API paths before routing them, so /api/graphql becomes /gitlab/api/graphql. On instances served on the domain root, nothing happens.
Changes:
- Pass instance's URL prefix into Duo Workflow action handler
- Prepend it to action paths in
buildRequest
References
- RFH that kicked off the work streams https://gitlab.com/gitlab-com/request-for-help/-/work_items/4857#note_3431715421
- Duo Chat (Agentic) WebSocket connection fails w... (#588861 - closed)
How to set up and validate locally
- Start up GDK in self hosted mode with DAP: https://gitlab-org.gitlab.io/gitlab-development-kit/howto/ai/duo_agent_platform/
- Configure self hosted models and set a self hosted model for agentic chat
- Set
relative_url_root: /gdk-instanceingdk.yml, thengdk reconfigure && gdk restart. - Rebuild Workhorse:
make gitlab-workhorse(after you checkout this MR) - Open up agentic chat and send a msg. It should respond instead of erroring out
See screencast:
screencast_fix_dap_for_relative_url.webm
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 #588861 (closed)
Related to gitlab-org/modelops/applied-ml/code-suggestions/ai-assist#2071 (closed)