Objective
Fix buildCustomJobs() in pkg/workflow/compiler_jobs.go to correctly handle runs-on values that are arrays or objects, not just strings.
Context
From discussion #19383 (HIGH-2): The current code does a string type assertion on runs-on:
if runsOnStr, ok := runsOn.(string); ok {
job.RunsOn = "runs-on: " + runsOnStr
}
// array/object: falls through silently, job.RunsOn stays ""
When runs-on is an array (e.g., [self-hosted, linux, large]), the assertion fails, job.RunsOn stays empty, and the compiled YAML is invalid — missing the required runs-on field. The top-level runs-on correctly uses extractTopLevelYAMLSection which handles all forms.
Approach
In pkg/workflow/compiler_jobs.go, in buildCustomJobs() around line 465, update the runs-on extraction:
- For the string case: keep existing behavior (
"runs-on: " + runsOnStr)
- For array and object cases: use
goccy/go-yaml to marshal the value back to a YAML snippet, then prepend "runs-on: "
- Add a validation error if
runs-on is present but cannot be marshaled
Example target output for array form:
runs-on:
- self-hosted
- linux
- large
Files to Modify
pkg/workflow/compiler_jobs.go — update runs-on handling in buildCustomJobs()
Acceptance Criteria
Generated by Plan Command for issue #discussion #19383 · ◷
Objective
Fix
buildCustomJobs()inpkg/workflow/compiler_jobs.goto correctly handleruns-onvalues that are arrays or objects, not just strings.Context
From discussion #19383 (HIGH-2): The current code does a string type assertion on
runs-on:When
runs-onis an array (e.g.,[self-hosted, linux, large]), the assertion fails,job.RunsOnstays empty, and the compiled YAML is invalid — missing the requiredruns-onfield. The top-levelruns-oncorrectly usesextractTopLevelYAMLSectionwhich handles all forms.Approach
In
pkg/workflow/compiler_jobs.go, inbuildCustomJobs()around line 465, update theruns-onextraction:"runs-on: " + runsOnStr)goccy/go-yamlto marshal the value back to a YAML snippet, then prepend"runs-on: "runs-onis present but cannot be marshaledExample target output for array form:
Files to Modify
pkg/workflow/compiler_jobs.go— updateruns-onhandling inbuildCustomJobs()Acceptance Criteria
runs-on: ubuntu-latest(string) continues to work correctlyruns-on: [self-hosted, linux, large](array) compiles to valid YAMLruns-on: {group: my-runners}(object) compiles to valid YAMLruns-onvalues produce a validation error (not silent empty output)runs-onformsmake agent-finishbefore committing