You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
refactor(github): extract the connection probe into an internal helper - #2723
This follows up on Merill's suggestion on #2633 to move the nested connection probe into its own internal GitHub helper.
Connect-MtGitHub now passes the request URI, authentication headers and shared rate-limit connection to Invoke-MtGitHubConnectionProbe. The request and response handling, 30-second connection and operation timeouts, error classification and cooldown transfer remain unchanged. Administration-probe failures still allow the connection to complete. There are no public API or authentication changes.
The existing connection and rate-limit tests cover the explicit inputs, shared connection identity, response/error handling and cooldowns at each probe.
All 120 focused connection and rate-limit tests passed.
All 108 connection and rate-limit tests passed against the built module.
All 31 expanded rate-limit tests also passed against the unchanged base.
Changed-file PSScriptAnalyzer, module build and output validation passed.
The complete ./powershell/tests/pester.ps1 run reported 7,064 tests, including 93 skips and five failures. All five failures reproduced on unchanged base bb7a0e8cc: one console-colour assertion and four Azure request URI assertions. Those failures are outside this change. The GitHub transport tests, including the real loopback timeout fixtures, passed in the full run.
No live GitHub connection was used for validation. Network-dependent tests use mocks or local loopback fixtures.
Checks
My pull request adheres to the code style of this project.
My code requires changes to the documentation.
I have updated the documentation as required.
The build and unit tests pass after running /powershell/tests/pester.ps1 locally.
The helper includes comment-based help. The full-suite checkbox is left unchecked because of the baseline failures described above.
Summary by CodeRabbit
Bug Fixes
GitHub connection checks now consistently respect shared API rate limits across user, organization, membership, and Actions permissions checks.
When a connection check succeeds or fails, rate-limit information is retained. Requests remain blocked when the applicable limit is exhausted, helping prevent avoidable API calls.
No actionable comments were generated in the recent review.
Walkthrough
The GitHub connection probe moved to an internal service helper. All four bootstrap probes now use it with shared headers and connection state. The helper checks rate limits, sends timed GET requests, records response or error state, and returns responses or rethrows errors.
Changes: GitHub connection probes
Layer / File(s)
Summary
Extract the connection probe powershell/internal/services/github/Invoke-MtGitHubConnectionProbe.ps1, powershell/tests/functions/Connect-MtGitHub.Tests.ps1
The helper checks rate limits before requests, sends GET requests with 30-second connection and operation timeouts, and records responses or errors. Tests cover request ordering, response handling, and error propagation.
Route bootstrap probes through the helper powershell/public/connect/Connect-MtGitHub.ps1, powershell/tests/functions/Connect-MtGitHub.Tests.ps1, powershell/tests/functions/GitHubRateLimit.Tests.ps1
The user, organization, membership, and administration probes use the helper with shared headers and connection state. Tests cover helper usage and rate-limit outcomes across all four probes.
No actionable regression was identified in the connection-probe extraction. Merge readiness remains subject to normal validation.
Pre-merge checks: 5
Check name
Status
Explanation
Title check
The title "refactor(github): extract the connection probe into an internal helper" matches the main change. The PR moves the nested connection probe out of Connect-MtGitHub into the internal helper In…
Description check
The description follows the repository template's main sections. It has a Description section that explains the helper extraction, the explicit inputs, the unchanged timeouts, error handling, and cool…
Linked Issues check
Issue #2674 is the only active direct target. Its coding requirements are met at head 6edfa3e:
1. Helper: powershell/internal/services/github/Invoke-MtGitHubConnectionProbe.ps1 defines one functi…
Out of Scope Changes check
All changed areas connect to #2674:
- Invoke-MtGitHubConnectionProbe.ps1 (new internal helper): the extracted probe logic that the issue requests. - Connect-MtGitHub.ps1: the four call sites swit…
Docstring Coverage
No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Full details: Title check
Explanation
The title "refactor(github): extract the connection probe into an internal helper" matches the main change. The PR moves the nested connection probe out of Connect-MtGitHub into the internal helper Invoke-MtGitHubConnectionProbe, and the title names that refactor and its scope. It is specific and concise, and it does not describe anything absent from the changeset.
Full details: Description check
Explanation
The description follows the repository template's main sections. It has a Description section that explains the helper extraction, the explicit inputs, the unchanged timeouts, error handling, and cooldown behavior. It has a Validation section with test results and baseline failures, and it has the Checks list. It also states the linked issue, #2674. Gaps: the 'Closes' line is filled in, but the template's introductory code-freeze notice is not addressed. The template's bug-fix-only code-freeze rule for Maester 3.0 (from 7 November 2026) applies to this PR, which is a refactor and not a bug fix. The author did not acknowledge that rule. The Additional Information section is also not used, and two checkboxes are unchecked, which the author explains. The description is mostly complete, so the check passes.
Full details: Linked Issues check
Explanation
Issue #2674 is the only active direct target. Its coding requirements are met at head 6edfa3e:
Helper: powershell/internal/services/github/Invoke-MtGitHubConnectionProbe.ps1 defines one function with the approved verb Invoke and a GitHub-specific name. It takes explicit -Uri, -Headers and -Connection parameters.
Routing: Connect-MtGitHub.ps1 sends the token identity, organization, membership and administration probes through the helper. The local nested Invoke-ConnectionProbe is removed. Each call passes $authHeaders and the same $rateLimitConnection.
Behavior: the helper runs Invoke-MtGitHubRateLimitGuard before the GET request and after the response or error. It keeps -ConnectionTimeoutSeconds 30 and -OperationTimeoutSeconds 30. It rethrows errors. The admin-probe catch logic is not in the diff, so its non-blocking behavior is unchanged.
Session state: the same $rateLimitConnection object is used across all probes, so cooldown state carries forward.
Tests: Connect-MtGitHub.Tests.ps1 adds a test that asserts all four probes use the helper with the same connection object and auth headers. It also adds helper tests for guard order, GET options, response return and error rethrow. The summary reports that GitHubRateLimit.Tests.ps1 covers cooldown retention and blocking or non-blocking probe failures. I did not inspect that file directly.
Non-coding items (PSScriptAnalyzer run, module build, full-suite run, baseline failure reporting) are excluded from this verdict.
Full details: Out of Scope Changes check
Explanation
All changed areas connect to #2674:
Invoke-MtGitHubConnectionProbe.ps1 (new internal helper): the extracted probe logic that the issue requests.
Connect-MtGitHub.ps1: the four call sites switch to the helper and the local function is removed. The diff shows no other behavior change.
Connect-MtGitHub.Tests.ps1: tests for helper routing and helper behavior, which the issue requests.
GitHubRateLimit.Tests.ps1: per the summary, primary-exhaustion coverage across the four probes, including cooldown retention. This matches the issue's requested cooldown-retention coverage. The change replaces an earlier two-case test. I did not inspect this file directly.
The helper is internal and the PR reports no changes to exported declarations. No unrelated feature, refactor or documentation change was found in the reviewed diffs.
Full details: Docstring Coverage
Explanation
No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 0 files. (4 skipped: 4 unsupported.)
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Tip
🎯 Customize your risk assessments
Guide how CodeRabbit assesses merge risk and security architecture risk. Highlight sensitive changes and explain your security boundaries using Merge Risk Instructions and Security Risk Instructions in your review settings. Security architecture risk assessments require the Advanced plan or above.
✅ Automatic approvals, with your rules
Let CodeRabbit approve pull requests once required threads are resolved, pre-merge checks pass, and your risk limits are met. Enable Automatic approvals in review settings, with overrides for teams or file paths.
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.
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer TIP This summary will be updated as you push new changes.
The reason will be displayed to describe this comment to others. Learn more.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
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
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.
Description
This follows up on Merill's suggestion on #2633 to move the nested connection probe into its own internal GitHub helper.
Connect-MtGitHubnow passes the request URI, authentication headers and shared rate-limit connection toInvoke-MtGitHubConnectionProbe. The request and response handling, 30-second connection and operation timeouts, error classification and cooldown transfer remain unchanged. Administration-probe failures still allow the connection to complete. There are no public API or authentication changes.The existing connection and rate-limit tests cover the explicit inputs, shared connection identity, response/error handling and cooldowns at each probe.
Closes #2674.
Validation
On Linux / PowerShell 7.6.6 / Pester 5.7.1:
The complete
./powershell/tests/pester.ps1run reported 7,064 tests, including 93 skips and five failures. All five failures reproduced on unchanged basebb7a0e8cc: one console-colour assertion and four Azure request URI assertions. Those failures are outside this change. The GitHub transport tests, including the real loopback timeout fixtures, passed in the full run.No live GitHub connection was used for validation. Network-dependent tests use mocks or local loopback fixtures.
Checks
/powershell/tests/pester.ps1locally.The helper includes comment-based help. The full-suite checkbox is left unchecked because of the baseline failures described above.
Summary by CodeRabbit