Skip to content

Fix PSScriptAnalyzer job failing on push - #461271

Open
machinewrapped wants to merge 1 commit into
microsoft:masterfrom
machinewrapped:fix/scriptanalyzer-pipeline-upstream
Open

machinewrapped wants to merge 1 commit into
microsoft:masterfrom
machinewrapped:fix/scriptanalyzer-pipeline-upstream

Conversation

@machinewrapped

@machinewrapped machinewrapped commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Problem

The PSScriptAnalyzer workflow fails on pushes to master with "Object reference not set to an instance of an object", thrown from Invoke-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 *.ps1 and *.psm1 output into Invoke-ScriptAnalyzer. Piping those FileInfo objects triggers a null reference inside PSScriptAnalyzer. Passing the same files by path does not.

Fix

  • Replace the two piped calls with $results = @(Invoke-ScriptAnalyzer -Path . -Recurse). This analyzes .ps1, .psm1 and .psd1 under the repo, matching the workflow's path filters. The Error check and exit code are unchanged.
  • Add .github/workflows/scriptAnalyzer.yaml to the pull_request and push path filters, so edits to the job itself trigger a run.

Verification

  • Locally, the piped form reproduces the error; -Path . -Recurse completes with 1063 findings and 0 Error-severity findings.
  • The same change passes the PSScriptAnalyzer job for both pull_request and push events on a fork of this repo.

🤖 Generated with Claude Code

Microsoft Reviewers: Open in CodeFlow

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>
@microsoft-github-policy-service

Copy link
Copy Markdown
Contributor

Validation Pipeline Badge Publish Pipeline Badge

@wingetvalidator-prod wingetvalidator-prod Bot added the Project-File The pull request modifies repository project or configuration files. label Oct 25, 2026
@microsoft-github-policy-service

Copy link
Copy Markdown
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

@microsoft-github-policy-service microsoft-github-policy-service Bot added the Needs-Attention This work item needs to be reviewed by a member of the core team. label Oct 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs-Attention This work item needs to be reviewed by a member of the core team. Project-File The pull request modifies repository project or configuration files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants