Skip to content

Add API validation and credential checks for GitLab triggers #1184

@geoffjay

Description

@geoffjay

Summary

Add API-level validation and credential checking for GitLab trigger configurations in the orchestrator's workflow creation endpoint, following the pattern established for Linear triggers.

Context

When creating a workflow via POST /workflows, the orchestrator validates trigger configs (e.g., non-empty owner/repo for GitHub, at least one filter for Linear, valid cron expressions). GitLab triggers need similar validation plus a credential check so users get clear errors at workflow creation time rather than silent failures on the first poll.

Acceptance Criteria

  • Add validation case for TriggerConfig::GitlabIssues in create_workflow() in crates/orchestrator/src/scheduler/api.rs:
    • owner and repo must be non-empty
    • state must be one of opened, closed, all (GitLab uses opened not open)
  • Add validation case for TriggerConfig::GitlabMergeRequests:
    • owner and repo must be non-empty
    • state must be one of opened, closed, merged, all
  • Add credential check (following Linear pattern at line 206):
    if matches!(req.trigger_config, TriggerConfig::GitlabIssues { .. } | TriggerConfig::GitlabMergeRequests { .. })
        && !crate::scheduler::gitlab::GitlabConfig::is_configured()
    {
        return Err(ApiError::InvalidInput(
            "GitLab token not configured. Set AGENTD_GITLAB_TOKEN or add 'token' to [gitlab] in config."
        ));
    }
  • Add GitLab variant to WebhookSource enum in crates/orchestrator/src/scheduler/types.rs for future webhook support (optional, can be deferred)
  • Ensure unknown/extra fields in GitLab trigger YAML produce clear deserialization errors

Key Files

  • crates/orchestrator/src/scheduler/api.rs - validation logic
  • crates/orchestrator/src/scheduler/types.rs - optional WebhookSource variant
  • crates/orchestrator/src/scheduler/gitlab.rs - GitlabConfig::is_configured()

Blocked By

  • The GitLab scaffolding issue (TriggerConfig variants and GitlabConfig must exist)

Stack Base

Branch off: feature/autonomous-pipeline
Blocked by: #1180

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions