Repository navigation
Fix PSScriptAnalyzer job failing on push - #461271
Open
machinewrapped wants to merge 1 commit into
Open
machinewrapped wants to merge 1 commit into
machinewrapped wants to merge 1 commit into
Conversation
The PSScriptAnalyzer workflow failed on pushes to master with "Object reference not set to an instance of an object", thrown from Invoke-ScriptAnalyzer. The step was reporting a crash, not lint findings. Cause: the step ran Get-ChildItem -Filter *.ps1 and *.psm1 and piped the FileInfo objects into Invoke-ScriptAnalyzer. Piping those objects into the analyzer triggers a null reference inside PSScriptAnalyzer. Passing the same files by path does not. Because the error is raised inside the analyzer, the job failed even though the lint itself found no Error-severity issues. Fix: replace the two piped calls with a single $results = @(Invoke-ScriptAnalyzer -Path . -Recurse). This analyzes .ps1, .psm1 and .psd1 under the repo, which matches the workflow's path filters. The Error check and exit code are unchanged. Also add .github/workflows/scriptAnalyzer.yaml to the pull_request and push path filters, so edits to the analyzer job itself trigger a run. Verification: locally, the piped form reproduces the error, while -Path . -Recurse completes with 1063 findings and 0 Error-severity findings. On this PR, the PSScriptAnalyzer job passes for both the pull_request and push events. Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
machinewrapped
requested review from
a team and
Demitrius Nelon (denelon)
as code owners
October 25, 2026 07:28
Contributor
Contributor
|
Changes to one or more files in your PR require authorization to modify. This PR has been assigned to our on call staff to evaluate. Template: msftbot/requiresApproval/MSFT |
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.
Problem
The PSScriptAnalyzer workflow fails on pushes to
masterwith "Object reference not set to an instance of an object", thrown fromInvoke-ScriptAnalyzer. The job reports a crash, not lint findings. Example: https://github.com/machinewrapped/winget-pkgs/actions/runs/40105918911 (from a fork with the same workflow).The step pipes
Get-ChildItem -Filter *.ps1and*.psm1output intoInvoke-ScriptAnalyzer. Piping thoseFileInfoobjects triggers a null reference inside PSScriptAnalyzer. Passing the same files by path does not.Fix
$results = @(Invoke-ScriptAnalyzer -Path . -Recurse). This analyzes.ps1,.psm1and.psd1under the repo, matching the workflow's path filters. TheErrorcheck and exit code are unchanged..github/workflows/scriptAnalyzer.yamlto thepull_requestandpushpath filters, so edits to the job itself trigger a run.Verification
-Path . -Recursecompletes with 1063 findings and 0Error-severity findings.pull_requestandpushevents on a fork of this repo.🤖 Generated with Claude Code
Microsoft Reviewers: Open in CodeFlow