Skip to content

GitLab agent template missing CODE_ALLOWED_TARGET_BRANCHES (harness env validation failure) #6273

Description

@ggallen

Problem

The GitLab code agent fails at harness env validation before the pre-script runs:

Error: validating env: env.runner[CODE_ALLOWED_TARGET_BRANCHES]: host variable CODE_ALLOWED_TARGET_BRANCHES is not set (referenced in "${CODE_ALLOWED_TARGET_BRANCHES}")

Pipeline: https://gitlab.cee.redhat.com/gallen/integration-service/-/pipelines/17086031

Root cause

harness/code.yaml (fullsend-ai/agents) declares CODE_ALLOWED_TARGET_BRANCHES: "${CODE_ALLOWED_TARGET_BRANCHES}" in the top-level env.runner section. The harness engine's os.Expand rejects unset variables.

On GitHub, reusable-code.yml:191 sets this to '' in the workflow env block — the variable exists (empty), so os.Expand succeeds and the post-script's ${CODE_ALLOWED_TARGET_BRANCHES:-} check skips the branch restriction logic.

On GitLab, fullsend-agent.yml only sets FULLSEND_FORGE: "gitlab" in its variables: section. CODE_ALLOWED_TARGET_BRANCHES is never set, so the harness engine fails.

Fix

Add CODE_ALLOWED_TARGET_BRANCHES: '' to the GitLab agent template's variables: section in internal/scaffold/fullsend-repo-gitlab/.gitlab/ci/fullsend-agent.yml, matching the GitHub pattern.

Broader pattern

Any top-level env.runner variable in a harness that uses a "${VAR}" passthrough will fail on GitLab if the variable isn't set in the GitLab CI config. Currently affected harnesses with top-level passthroughs:

Harness Variable Multi-forge? Affected?
code.yaml CODE_ALLOWED_TARGET_BRANCHES Yes (GitHub + GitLab) Yes — current failure
fix.yaml TARGET_BRANCH, TRIGGER_SOURCE, HUMAN_INSTRUCTION, FIX_ITERATION, REVIEW_BODY_FILE, PRE_AGENT_HEAD No (GitHub-only) Not yet — will break when multi-forged
scribe.yaml SCRIBE_REPO, SCRIBE_*, GH_TOKEN, CONTENTS_TOKEN No (GitHub-only) Not yet

triage.yaml and review.yaml have no top-level passthroughs, so they're unaffected.

Related: #5799 (verify ${VAR} substitution semantics for unset harness env vars)

Context

This surfaced during the first real GitLab code agent run after fullsend-ai/agents#813 (multi-forge code agent, PR branch agent/807-multi-forge-code). The same pipeline previously hit GITLAB_HOST not set — that was fixed in the agents repo by removing GITLAB_HOST from the harness env (it's derived from ISSUE_URL at runtime by all consumers).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugcomponent/harnessAgent harness, config, and skills loadingpriority/highSignificant impact, address soonready-to-codeTriaged and ready for the code agenttype/bugConfirmed defect in existing behavior

    Type

    No type

    Projects

    Status
    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions