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).
Problem
The GitLab code agent fails at harness env validation before the pre-script runs:
Pipeline: https://gitlab.cee.redhat.com/gallen/integration-service/-/pipelines/17086031
Root cause
harness/code.yaml(fullsend-ai/agents) declaresCODE_ALLOWED_TARGET_BRANCHES: "${CODE_ALLOWED_TARGET_BRANCHES}"in the top-levelenv.runnersection. The harness engine'sos.Expandrejects unset variables.On GitHub,
reusable-code.yml:191sets this to''in the workflow env block — the variable exists (empty), soos.Expandsucceeds and the post-script's${CODE_ALLOWED_TARGET_BRANCHES:-}check skips the branch restriction logic.On GitLab,
fullsend-agent.ymlonly setsFULLSEND_FORGE: "gitlab"in itsvariables:section.CODE_ALLOWED_TARGET_BRANCHESis never set, so the harness engine fails.Fix
Add
CODE_ALLOWED_TARGET_BRANCHES: ''to the GitLab agent template'svariables:section ininternal/scaffold/fullsend-repo-gitlab/.gitlab/ci/fullsend-agent.yml, matching the GitHub pattern.Broader pattern
Any top-level
env.runnervariable 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:code.yamlCODE_ALLOWED_TARGET_BRANCHESfix.yamlTARGET_BRANCH,TRIGGER_SOURCE,HUMAN_INSTRUCTION,FIX_ITERATION,REVIEW_BODY_FILE,PRE_AGENT_HEADscribe.yamlSCRIBE_REPO,SCRIBE_*,GH_TOKEN,CONTENTS_TOKENtriage.yamlandreview.yamlhave 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 hitGITLAB_HOSTnot set — that was fixed in the agents repo by removingGITLAB_HOSTfrom the harness env (it's derived fromISSUE_URLat runtime by all consumers).