fix: retry the in-build Lint task on PSScriptAnalyzer's transient null reference#67
Conversation
…l reference PSScriptAnalyzer 1.25.0 intermittently throws "Object reference not set to an instance of an object." from inside the analyzer engine, failing the Lint task on otherwise-green builds. It has struck both Linux (#65) and Windows (#66) CI runners at random, so it is not platform-specific and a non-Windows disable would not cover it. Retry the analysis up to three times on that specific null reference, while letting any genuine analysis error surface immediately. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe ChangesLint task with NullReferenceException retry
Possibly related PRs
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
Adds a small retry loop around Invoke-ScriptAnalyzer in the custom Lint psake task to mitigate a transient NullReferenceException ("Object reference not set to an instance of an object.") thrown intermittently by PSScriptAnalyzer 1.25.0 on otherwise-green CI builds. Genuine analysis errors still surface immediately, and exhausting all attempts still fails the build.
Changes:
- Wrap
Invoke-ScriptAnalyzerin a 3-attempt retry loop with a 1-second backoff. - Detect transient null-reference failures via exception type, inner exception type, or message substring.
- Rethrow non-matching exceptions and rethrow on the final attempt.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
Object reference not set to an instance of an object.from inside the analyzer engine, failing the in-buildLinttask (build.psake.ps1) on otherwise-green builds.Linttask now retriesInvoke-ScriptAnalyzerup to three times on that specific null reference (matched by exception type, inner exception, or message), while letting any genuine analysis error surface immediately and still failing after the final attempt.Test Plan
build.psake.ps1parses clean; no new PSScriptAnalyzer findings introducedpwsh -File ./build.ps1 -Task Lintpasses locally (errors: 0)Breaking Changes
None — build/CI tooling only; no module behavior changes.
🤖 Generated with Claude Code
Summary by CodeRabbit