Create Workflow REST api does not use default namespace preference

Problem to solve

When creating workflows using the REST api POST /api/v4/ai/duo_workflows/workflows a projectId and namespaceId must be provided, otherwise a 400 response is returned.

This means it is not possible to create workflows outside of a gitlab project, and impossible to make use of the users configured duo_default_namespace_with_fallback.

When using GraphQL to create workflows, these properties are NOT required, and it correctly falls back to the users configured default namespace.

Proposed solution

Update the REST API to allow creating workflows without providing a projectId, namespaceId. Implement equivalent fallback logic as the GraphQL endpoint:

container = if args[:project_id]
              GitlabSchema.find_by_gid(args[:project_id]).sync
            elsif args[:namespace_id]
              GitlabSchema.find_by_gid(args[:namespace_id]).sync
            else
              current_user.user_preference.duo_default_namespace_with_fallback
            end
Edited by 🤖 GitLab Bot 🤖