Conversation
…k to fix variable-not-set error Co-authored-by: blindzero <13959569+blindzero@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix ExchangeOnline provider authentication to bearerToken error
Fix: ExchangeOnline provider InvokeSafely fails with variable-not-set error on bearer token sanitization
Feb 23, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a scoping bug in the Exchange Online provider’s internal adapter where InvokeSafely could throw a variable-not-set error when called via $this.InvokeSafely() from another ScriptMethod, and adds a regression test to prevent recurrence.
Changes:
- Move bearer/token sanitization regex patterns into the
InvokeSafelyScriptMethod body to ensure they’re always in scope at call time. - Add Pester regression coverage ensuring
InvokeSafelyworks when invoked via$thisand that bearer tokens are redacted in thrown error messages.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/IdLE.Provider.ExchangeOnline/Private/New-IdleExchangeOnlineAdapter.ps1 |
Fixes InvokeSafely scoping by defining sanitization regex patterns inside the ScriptMethod body. |
tests/Providers/ExchangeOnlineProvider.Tests.ps1 |
Adds a regression test context covering ScriptMethod-to-ScriptMethod invocation and bearer token redaction behavior. |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
blindzero
requested changes
Feb 23, 2026
Code Coverage Report
|
…rs.Providers.ps1 helper Co-authored-by: blindzero <13959569+blindzero@users.noreply.github.com>
blindzero
approved these changes
Feb 23, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
$bearerTokenPatternand$tokenAssignmentPatternare defined in the outer function scope but not captured in the$invokeSafelyScriptMethod closure$bearerTokenPatternand$tokenAssignmentPatterninside the$invokeSafelyscriptblockInvokeSafelyclosure behaviorfunction global:Invoke-ThrowBearerErrorwithInvoke-IdleTestBearerTokenErrorin_testHelpers.Providers.ps1; dot-source helpers in the contextBeforeAllto ensure availability at run timeOriginal prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.