Skip to content

ci(release): fail the PSGallery check on a query error instead of assuming not-published#34

Merged
tablackburn merged 2 commits into
mainfrom
ci/harden-psgallery-check
May 23, 2026
Merged

ci(release): fail the PSGallery check on a query error instead of assuming not-published#34
tablackburn merged 2 commits into
mainfrom
ci/harden-psgallery-check

Conversation

@tablackburn
Copy link
Copy Markdown
Owner

@tablackburn tablackburn commented May 22, 2026

Follow-up to the recovery-gap fix (#33). Now that Publish is gated only on the PSGallery check, that check's error handling matters: Find-Module -ErrorAction SilentlyContinue returns $null for both a genuine "not on gallery" and a transient query failure — so a network/PSGallery hiccup would be read as "not published" and trigger a blind publish attempt.

Fix: capture -ErrorVariable. A genuine not-found records no error (verified for an existing-module/new-version and a never-published module), so we publish only on a clean miss; a recorded error means the query itself failed → throw so the run is visibly retryable.

Surfaced by CodeRabbit + Copilot during the YouTubeMusicPS rollout review. Workflow YAML parses; no manifest change.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Chores
    • Enhanced error handling in the module publishing workflow. The version availability check now distinguishes between genuinely unavailable versions and transient query failures, ensuring accurate error detection. This prevents temporary network or service issues from being incorrectly interpreted as the module already being published.

Review Change Stack

…uming not-published

Now that Publish is gated only on this check (recovery-gap fix #33), a
Find-Module -ErrorAction SilentlyContinue returning $null was treated as
'not on gallery' for BOTH a genuine miss and a transient query failure — so a
network/PSGallery hiccup could trigger a blind publish attempt. Capture
-ErrorVariable: publish only on a clean miss (Find-Module records no error for a
genuine not-found, verified for new-version and never-published cases); on a
recorded error, throw so the run is visibly retryable.

Surfaced by CodeRabbit/Copilot during the YouTubeMusicPS rollout review.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 22, 2026 01:23
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 22, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d89beca5-f1c3-4c8b-a77f-a905436caa2b

📥 Commits

Reviewing files that changed from the base of the PR and between 090de78 and 282de8a.

📒 Files selected for processing (1)
  • .github/workflows/PublishModuleToPowerShellGallery.yaml

📝 Walkthrough

Walkthrough

The publish workflow's PowerShell Gallery version check now distinguishes query failures from missing versions. The step captures Find-Module errors via -ErrorVariable and throws if an error occurs, instead of treating transient failures as legitimate absence. It only marks exists=false when the query succeeds with no results.

Changes

PSGallery Version Check Error Handling

Layer / File(s) Summary
Find-Module error capture and failure behavior
.github/workflows/PublishModuleToPowerShellGallery.yaml
The PSGallery existence check now uses -ErrorVariable to capture Find-Module query failures, throws with the captured error message if an error occurs, and only marks exists=false when the query succeeds without finding the module/version.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A query goes out to the gallery store,
Error handling now knows what's adore—
No silent failures, no false "not found,"
Transient mishaps are caught and unwound!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: improving error handling in the PSGallery version check by failing on query errors instead of assuming the module is not published.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ci/harden-psgallery-check

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR tightens the PowerShell Gallery “already published?” gate in the release workflow so that transient Find-Module query failures no longer get misinterpreted as “not published,” preventing accidental blind publish attempts when PSGallery/network hiccups occur.

Changes:

  • Capture Find-Module failures via -ErrorVariable while still suppressing output with -ErrorAction SilentlyContinue.
  • Fail the workflow explicitly (throw) when the PSGallery query errors, while continuing to treat a clean miss as “not published”.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@tablackburn
Copy link
Copy Markdown
Owner Author

@coderabbitai full review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 22, 2026

✅ Actions performed

Full review triggered.

@tablackburn
Copy link
Copy Markdown
Owner Author

@coderabbitai full review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 22, 2026

✅ Actions performed

Full review triggered.

@tablackburn
Copy link
Copy Markdown
Owner Author

@coderabbitai full review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 22, 2026

✅ Actions performed

Full review triggered.

@tablackburn tablackburn merged commit 982286a into main May 23, 2026
11 checks passed
@tablackburn tablackburn deleted the ci/harden-psgallery-check branch May 23, 2026 05:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants