Skip to content

refactor: rename Azure DevOps connection cache#1864

Merged
merill merged 4 commits into
mainfrom
codex/rename-ado-connection-cache
Jul 6, 2026
Merged

refactor: rename Azure DevOps connection cache#1864
merill merged 4 commits into
mainfrom
codex/rename-ado-connection-cache

Conversation

@merill

@merill merill commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Summary

Renames the internal Azure DevOps connection probe cache from AzureDevOpsConnection to AzureDevOpsConnectionCache.

This makes the lifecycle clearer: the value is not the source Azure DevOps auth/session state, it is only Maester's cached result from probing Get-ADOPSConnection inside Test-MtConnection.

Changes

  • Renamed the session key in Test-MtConnection and Clear-ModuleVariable.
  • Updated the module build template and module session initialization.
  • Added focused tests for successful, failed, cached, and cleared Azure DevOps probe states.

Validation

  • Invoke-Pester powershell/tests/functions/Test-MtConnection.Tests.ps1,powershell/tests/functions/Test-MtCaAzureDevOps.Tests.ps1 -Output Normal
  • Result: 7 passed, 0 failed.

Summary by CodeRabbit

  • Bug Fixes

    • Improved Azure DevOps connection caching to avoid repeated connection probes after failed attempts, by remembering negative results for the current session.
    • Refreshed cache reset behavior so connection probing resumes correctly when variables are cleared.
  • Tests

    • Expanded automated tests for Azure DevOps caching, covering successful caching, negative-result caching, reuse without re-probing, and proper cache invalidation/reset.

@coderabbitai

coderabbitai Bot commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 01e96a40-db44-4afc-b416-66d5a1663f89

📥 Commits

Reviewing files that changed from the base of the PR and between 3231e8c and 1d6c629.

📒 Files selected for processing (1)
  • powershell/tests/functions/Test-MtConnection.Tests.ps1
🚧 Files skipped from review as they are similar to previous changes (1)
  • powershell/tests/functions/Test-MtConnection.Tests.ps1

📝 Walkthrough

Walkthrough

Renames the Azure DevOps session cache field to AzureDevOpsConnectionCache in module initialization, clear logic, connection probing, and related tests. The test suite now covers cache population, cache reuse, negative caching, and cache cleanup.

Changes

AzureDevOps Connection Cache Rename

Layer / File(s) Summary
Session state and probe cache
powershell/Maester.psm1, build/Build-MaesterModule.ps1, powershell/internal/Clear-ModuleVariable.ps1, powershell/public/core/Test-MtConnection.ps1
__MtSession now initializes AzureDevOpsConnectionCache, Clear-ModuleVariable clears that field, and Test-MtConnection reads and writes the renamed cache for Azure DevOps connection probes, including the 'NotConnected' sentinel.
Azure DevOps cache tests
powershell/tests/functions/Test-MtConnection.Tests.ps1
Existing setup is updated to use AzureDevOpsConnectionCache, and new tests cover successful caching, failed caching, cache-hit reuse, and clearing the module state.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 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 summarizes the main change: renaming the Azure DevOps connection cache.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/rename-ado-connection-cache

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.

@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

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.

@merill merill marked this pull request as ready for review June 22, 2026 03:12
@merill merill requested a review from a team as a code owner June 22, 2026 03:12
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jun 22, 2026

Copy link
Copy Markdown

Deploying maester with  Cloudflare Pages  Cloudflare Pages

Latest commit: 1d6c629
Status: ✅  Deploy successful!
Preview URL: https://516d43d9.maester.pages.dev
Branch Preview URL: https://codex-rename-ado-connection.maester.pages.dev

View logs

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
build/Build-MaesterModule.ps1 (1)

470-483: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Keep build-generated session schema aligned with source initializer.

The preamble used to generate Maester.psm1 omits SpoCache, while powershell/Maester.psm1 initializes it. This creates a source/build contract mismatch and can surface null/missing-key behavior on SharePoint cache paths before a reset routine runs.

Proposed fix
 $__MtSession = @{
     GraphCache = @{}
     GraphBaseUri = $null
     TestResultDetail = @{}
     Connections = @()
     DnsCache = @()
     ExoCache = @{}
     OrcaCache = @{}
     AIAgentInfo = $null
     AzureDevOpsConnectionCache = $null
     DataverseApiBase = $null       # Resolved Dataverse OData API base URL (e.g. https://org123.api.crm.dynamics.com/api/data/v9.2)
     DataverseResourceUrl = $null   # Dataverse resource URL for token acquisition (e.g. https://org123.crm.dynamics.com)
     DataverseEnvironmentId = $null # Environment identifier for display (e.g. org123.crm.dynamics.com)
+    SpoCache = @{}                 # Cache for SharePoint Online tenant settings retrieved via PnP
 }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@build/Build-MaesterModule.ps1` around lines 470 - 483, The $__MtSession
hashtable is missing the SpoCache initialization that exists in the source file
powershell/Maester.psm1. Add SpoCache = @{} to the $__MtSession hashtable
definition to ensure the build-generated session schema matches the source
initializer and prevent null/missing-key errors when SharePoint cache operations
are executed.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@build/Build-MaesterModule.ps1`:
- Around line 470-483: The $__MtSession hashtable is missing the SpoCache
initialization that exists in the source file powershell/Maester.psm1. Add
SpoCache = @{} to the $__MtSession hashtable definition to ensure the
build-generated session schema matches the source initializer and prevent
null/missing-key errors when SharePoint cache operations are executed.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 0d8da1a4-5803-4b4f-bba5-05661ff73dee

📥 Commits

Reviewing files that changed from the base of the PR and between 3d1a881 and 43f7426.

📒 Files selected for processing (5)
  • build/Build-MaesterModule.ps1
  • powershell/Maester.psm1
  • powershell/internal/Clear-ModuleVariable.ps1
  • powershell/public/core/Test-MtConnection.ps1
  • powershell/tests/functions/Test-MtConnection.Tests.ps1

@SamErde

SamErde commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

@copilot resolve the merge conflicts in this pull request

Copilot AI commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

@copilot resolve the merge conflicts in this pull request

Resolved by merging origin/main and fixing the conflicts in commit 3231e8c2.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Renames Maester’s internal Azure DevOps connection probe cache session key to AzureDevOpsConnectionCache (clarifying it stores only the cached probe result from Test-MtConnection), and adds tests around Azure DevOps probe caching behavior.

Changes:

  • Renamed the Azure DevOps probe cache key throughout Test-MtConnection, module session initialization, and module-variable reset.
  • Updated the build template session initialization to match the new cache key.
  • Added focused Pester tests covering successful probe caching, negative-result caching, cache reuse, and cache clearing.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
powershell/tests/functions/Test-MtConnection.Tests.ps1 Updates existing tests for the new cache key and adds new Azure DevOps cache behavior tests.
powershell/public/core/Test-MtConnection.ps1 Switches Azure DevOps probe caching to the new AzureDevOpsConnectionCache session key.
powershell/Maester.psm1 Initializes the new Azure DevOps cache key in the module session state.
powershell/internal/Clear-ModuleVariable.ps1 Clears the new Azure DevOps cache key during module-variable reset.
build/Build-MaesterModule.ps1 Updates the module build template to initialize the new cache key.

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

Comment thread powershell/public/core/Test-MtConnection.ps1
Comment thread powershell/tests/functions/Test-MtConnection.Tests.ps1 Outdated
Comment thread powershell/tests/functions/Test-MtConnection.Tests.ps1 Outdated
Comment thread powershell/tests/functions/Test-MtConnection.Tests.ps1 Outdated
Comment thread powershell/tests/functions/Test-MtConnection.Tests.ps1 Outdated
SamErde
SamErde previously approved these changes Jul 3, 2026
@SamErde

This comment was marked as duplicate.

@SamErde

SamErde commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Looks good to me. Ready for final review and approval by someone other than me because I made the last push.

@merill

merill commented Jul 6, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the review and updates @SamErde

@merill merill merged commit c7ddd5f into main Jul 6, 2026
10 of 11 checks passed
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.

4 participants