Skip to content

[plan] Fix custom jobs runs-on array and object forms being silently dropped #19400

@github-actions

Description

@github-actions

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:

  1. For the string case: keep existing behavior ("runs-on: " + runsOnStr)
  2. For array and object cases: use goccy/go-yaml to marshal the value back to a YAML snippet, then prepend "runs-on: "
  3. 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

  • runs-on: ubuntu-latest (string) continues to work correctly
  • runs-on: [self-hosted, linux, large] (array) compiles to valid YAML
  • runs-on: {group: my-runners} (object) compiles to valid YAML
  • Invalid runs-on values produce a validation error (not silent empty output)
  • Unit tests added for all three runs-on forms
  • Run make agent-finish before committing

Generated by Plan Command for issue #discussion #19383 ·

  • expires on Mar 5, 2026, 10:49 AM UTC

Metadata

Metadata

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions