🪲 [Fix]: Pipeline bulk deletion of workflow runs no longer silently drops items#573
Open
Marius Storhaug (MariusStorhaug) wants to merge 1 commit intomainfrom
Open
🪲 [Fix]: Pipeline bulk deletion of workflow runs no longer silently drops items#573Marius Storhaug (MariusStorhaug) wants to merge 1 commit intomainfrom
Marius Storhaug (MariusStorhaug) wants to merge 1 commit intomainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes bulk deletion of workflow runs via pipeline by ensuring workflow run objects are constructed reliably and deletion errors don’t terminate the pipeline.
Changes:
- Updated
Remove-GitHubWorkflowRunto wrap the delete API call intry/catchand emit a non-terminating error per failed run. - Fixed
GitHubWorkflowRunconstructor to use the$Objectparameter consistently instead of relying on leaked$_.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/functions/public/Workflows/Runs/Remove-GitHubWorkflowRun.ps1 |
Makes pipeline deletions resilient by catching API failures and continuing with remaining items. |
src/classes/public/Workflows/GitHubWorkflowRun.ps1 |
Removes reliance on $_ leakage in the constructor by switching all assignments to $Object.*. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Piping workflow runs from
Get-GitHubWorkflowRunthroughWhere-ObjectintoRemove-GitHubWorkflowRunnow correctly processes all matching items. Previously, only a subset of runs were deleted and the rest were silently skipped.Fixed: All pipeline items now processed during bulk deletion
Bulk deletion via pipeline now works end-to-end:
Previously, this pattern could silently skip most workflow runs. Now all matching runs are deleted, and any individual failures are reported as non-terminating errors without interrupting the remaining deletions.
Fixed: Deletion failures no longer kill the pipeline
If a single workflow run cannot be deleted (e.g., due to a conflict or permission issue), the error is now reported with the run ID and the pipeline continues processing remaining items. Previously, a terminating error from the GitHub API would stop the entire pipeline, leaving subsequent runs undeleted with no indication of what happened.
Technical Details
GitHubWorkflowRunconstructor: All property assignments used$_(the automatic pipeline variable from the callingForEach-Objectscope) instead of the$Objectconstructor parameter. This relied on undocumented PowerShell behavior where$_leaks fromForEach-Objectinto class constructors. Replaced all$_references with$Objectfor correctness and reliability across PowerShell versions.Remove-GitHubWorkflowRun: Wrapped theInvoke-GitHubAPIcall intry/catchto convert terminating API errors into non-terminating errors (Write-Error). The error message includes the run ID, owner, and repository for diagnostics. MovedWrite-Verboseinside thetryblock so it only emits on successful deletion.Remove-*/Set-*/Add-*functions for the same pipeline-killing error handling pattern.