🪲 [Fix]: Pipeline bulk deletion of workflow runs no longer silently drops items#573
🪲 [Fix]: Pipeline bulk deletion of workflow runs no longer silently drops items#573Marius Storhaug (MariusStorhaug) wants to merge 12 commits into
Conversation
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.*. |
Super-linter summary
All files and directories linted successfully For more information, see the GitHub Actions workflow run Powered by Super-linter |
Super-linter summary
All files and directories linted successfully For more information, see the GitHub Actions workflow run Powered by Super-linter |
Verifies all scalar properties are populated from the $Object parameter, not from the caller's $_. Constructing outside ForEach-Object ensures is null — if the constructor incorrectly references instead of , the assertions will fail.
Super-linter summary
All files and directories linted successfully For more information, see the GitHub Actions workflow run Powered by Super-linter |
Super-linter summary
All files and directories linted successfully For more information, see the GitHub Actions workflow run Powered by Super-linter |
Agent-Logs-Url: https://github.com/PSModule/GitHub/sessions/4544dc21-9d62-448f-b51c-16fb320e09af Co-authored-by: MariusStorhaug <17722253+MariusStorhaug@users.noreply.github.com>
Super-linter summary
All files and directories linted successfully For more information, see the GitHub Actions workflow run Powered by Super-linter |
Agent-Logs-Url: https://github.com/PSModule/GitHub/sessions/3cabdfbb-e30f-4f65-9bd0-4a90b49ed738 Co-authored-by: MariusStorhaug <17722253+MariusStorhaug@users.noreply.github.com>
Agent-Logs-Url: https://github.com/PSModule/GitHub/sessions/3cabdfbb-e30f-4f65-9bd0-4a90b49ed738 Co-authored-by: MariusStorhaug <17722253+MariusStorhaug@users.noreply.github.com>
Agent-Logs-Url: https://github.com/PSModule/GitHub/sessions/3cabdfbb-e30f-4f65-9bd0-4a90b49ed738 Co-authored-by: MariusStorhaug <17722253+MariusStorhaug@users.noreply.github.com>
Agent-Logs-Url: https://github.com/PSModule/GitHub/sessions/3cabdfbb-e30f-4f65-9bd0-4a90b49ed738 Co-authored-by: MariusStorhaug <17722253+MariusStorhaug@users.noreply.github.com>
Agent-Logs-Url: https://github.com/PSModule/GitHub/sessions/2dc56a74-b30d-4c87-92fd-a00e4eba64b5 Co-authored-by: MariusStorhaug <17722253+MariusStorhaug@users.noreply.github.com>
Agent-Logs-Url: https://github.com/PSModule/GitHub/sessions/2dc56a74-b30d-4c87-92fd-a00e4eba64b5 Co-authored-by: MariusStorhaug <17722253+MariusStorhaug@users.noreply.github.com>
Super-linter summary
All files and directories linted successfully For more information, see the GitHub Actions workflow run Powered by Super-linter |
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.