`Index was out of range` in local composite action poststeps
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 6.3k
- Forks
- 1.4k
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 24
Description
Describe the bug
Invoke a local composite action like
- uses: ./.github/actions/composite
The post steps fail with
Error: Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'index')
To Reproduce
Create a workflow
## file: .github/workflow/poststeps.yaml
on:
workflow_dispatch:
inputs:
ref_one:
type: string
description: "The git ref to checkout"
default: main
jobs:
run:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/composite
with:
ref: ${{ inputs.ref_one }}
- uses: ./.github/actions/composite
Create a composite action that invokes actions/checkout
## file: .github/actions/composite/action.yaml
name: 'Hello World'
inputs:
ref:
description: The git ref to checkout
required: true
runs:
using: "composite"
steps:
- uses: actions/checkout@v3
with:
ref: ${{ inputs.ref }}
- run: echo Hello "${{ inputs.ref }}" >> $GITHUB_STEP_SUMMARY
shell: bash
After creating the files, create the tag v1.
Then update the composite action to change the number of steps.
cat << EOF >> .github/actions/composite/action.yaml
- run: echo Hello Again "${{ inputs.ref }}" >> $GITHUB_STEP_SUMMARY
shell: bash
EOF
Run the workflow with input ref=v1
Expected behavior
Expect the poststeps to not fail.
Runner Version and Platform
Current runner version: '2.308.0'
Operating System
Ubuntu
22.04.3
LTS
Runner Image
Image: ubuntu-22.04
Version: 20230821.1.0
Included Software: https://github.com/actions/runner-images/blob/ubuntu22/20230821.1/images/linux/Ubuntu2204-Readme.md
Image Release: https://github.com/actions/runner-images/releases/tag/ubuntu22%2F20230821.1
What's not working?
Post steps fail, which causes workflow status to fail.
Job Log Output
##[debug]Evaluating condition for step: 'Post Run /./.github/actions/composite'
##[debug]Evaluating: always()
##[debug]Evaluating always:
##[debug]=> true
##[debug]Result: true
##[debug]Starting: Post Run /./.github/actions/composite
Error: Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'index')
##[debug]System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'index')
##[debug] at GitHub.Runner.Worker.ActionManager.LoadAction(IExecutionContext executionContext, ActionStep action)
##[debug] at GitHub.Runner.Worker.ActionRunner.RunAsync()
##[debug] at GitHub.Runner.Worker.StepsRunner.RunStepAsync(IStep step, CancellationToken jobCancellationToken)
##[debug]Finishing: Post Run /./.github/actions/composite
Workarounds
This error is caused by a mismatch in the cached number of steps for the local composite action. Calling checkout causes the number of steps to change, which creates the error. To workaround...
- Avoid calling checkout in local composite actions, or ensure that checkout is always called with the same version.
- Call the action as a global composite action (e.g.,
uses: user/repo/.github/actions/composite@main)
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at GitHub.Runner.Worker.ActionManager.LoadAction, identified in the job log, and reproduce the failure with .github/workflow/poststeps.yaml and .github/actions/composite/action.yaml. Compare the cached and current composite-action step counts when actions/checkout changes the action, then run the workflow reproduction. Done means the local composite action's post steps complete without the index error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, github-actions
- Domain
- ci-cd, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 42/100