Resolve "Pass organization_id in the headers to Duo Workflow Service"

What does this MR do and why?

Adds organization id to request headers, this will allow us to track usage on a organization level.

  • It uses Current.organization if available
  • Determines organization with user's governing_namespace
    • The governing_namespace method follows this decision process:
      • If a scope (namespace context) is provided and the user is a member of that namespace's top-level group or any subgroups or projects within the top-level group, use the top-level group. Otherwise, use the user's selected default GitLab Duo namespace.
      • If the user has not selected a default namespace, attempt to infer one. Return nil if no suitable namespace can be determined.
  • Sends nil if no org is available

References

Screenshots or screen recordings

Before After
image.png image.png

How to set up and validate locally

  1. Enable AI Gateway in your dev env

  2. Trigger any duo workflow (via ui or curl)

  3. Check the headers, organization should be sent

     curl --request POST \
        --url "http://gdk.test:3000/api/v4/ai/duo_workflows/direct_access" \
        --header "Content-Type: application/json" \
        --header "PRIVATE-TOKEN: <PAT>" \
        --data '{
          "project_id": "1",
          "workflow_definition": "software_developer"
        }' | jq '.duo_workflow_service.headers'

    image.png

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 #596195

Edited by Homer Silva

Merge request reports

Loading