Skip to content

[plan] Fix YAML splicing corruption in jobs.{pre_activation,activation}.pre-steps #27746

Closed

Description

@github-actions

Context

Reported in #27670. When jobs.pre_activation.pre-steps or jobs.activation.pre-steps are set, injected pre-steps get spliced inside the auto-generated Setup Scripts step instead of after it, producing invalid YAML with duplicate uses:/with: keys that fails actionlint and GitHub Actions at runtime.

Root Cause

In pkg/workflow/compiler_jobs.go, insertPreStepsAfterSetupBeforeCheckout uses the regex (?m)^\s*id:\s*setup\s*$ to find the splice point, then sets insertIdx = lastSetupIdx + 1.

However, generateSetupStep in pkg/workflow/compiler_yaml_step_generation.go emits the Setup Scripts step as multiple separate []string entries (one per YAML line):

  • index N: - name: Setup Scripts\n
  • index N+1: id: setup\n ← regex matches here
  • index N+2: uses: ...\n ← splice happens here, mid-step

This splits the step's YAML block in half.

Objective

Fix the splice-point logic so pre-steps are inserted after the complete Setup Scripts step.

Approach

Choose Option A (preferred) from the issue:

  • Detect the end of the Setup Scripts step by finding the next entry that starts a new step (begins with - at the same indentation level), and use that index as the splice point — rather than lastSetupIdx + 1.

Alternatively:

  • Emit the Setup Scripts step as a single []string entry containing the full multi-line YAML block.

Files to Modify

  • pkg/workflow/compiler_jobs.go — fix insertPreStepsAfterSetupBeforeCheckout splice logic
  • pkg/workflow/compiler_yaml_step_generation.go — (if taking single-entry approach) adjust generateSetupStep
  • pkg/workflow/compiler_jobs_test.go — add regression tests

Acceptance Criteria

Generated by Plan Command for issue #27670 · ● 242.8K · ◷

  • expires on Apr 24, 2026, 2:47 AM UTC

Activity

  1. added
    cookie
    on Apr 22, 2026
  2. github-actions commented on Apr 22, 2026

    @github-actions
    ContributorAuthor

    🍪 *Issue Monster selected this for Copilotecho BEGIN___COMMAND_OUTPUT_MARKER ; PS1= ; PS2= ; unset HISTFILE ; EC=0 ; echo ___BEGIN___COMMAND_DONE_MARKER___0 ; }

    I've identified this issue as a good candidate for automated resolution and requested assignment to the Copilot coding agent.

    If assignment succeeds, the Copilot coding agent will analyze the issue and create a pull request with the fix.

    Om nom nom! 🍪

    Caution

    Security scanning requires review for Issue Monster

    Details

    Potential security threats were detected in the agent output. The workflow output should be reviewed before merging.

    Review the workflow run logs for details.

    🍪 Om nom nom by Issue Monster · ● 25.2K · ◷

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

ai-generatedcookieplan

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions