Conversation
Co-authored-by: blindzero <13959569+blindzero@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix EnsureAttributes in Provider.AD to allow unsetting attributes
Fix EnsureAttributes: null attribute values fail with MethodArguments binding error
Feb 22, 2026
blindzero
reviewed
Feb 22, 2026
… fix Co-authored-by: blindzero <13959569+blindzero@users.noreply.github.com>
blindzero
approved these changes
Feb 22, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a PowerShell parameter-binding edge case in IdLE’s provider invocation helper so EnsureAttributes can pass $null attribute values (used to clear/unset attributes) through the fallback path without failing before the provider is invoked.
Changes:
- Allow
$nullelements inInvoke-IdleProviderMethod’s-MethodArgumentsarray by adding[AllowNull()], while still rejecting a null array reference via an explicit guard. - Add a regression Pester test ensuring
Invoke-IdleStepEnsureAttributesfallback mode can process attributes whose desired values are$null.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/IdLE.Core/Public/Invoke-IdleProviderMethod.ps1 |
Adjusts parameter binding to permit argument arrays containing $null elements and adds a clearer runtime guard for a null array reference. |
tests/Steps/Invoke-IdleStepEnsureAttributes.Tests.ps1 |
Adds a regression test for $null attribute values flowing through the fallback (EnsureAttribute) invocation path. |
Comments suppressed due to low confidence (1)
tests/Steps/Invoke-IdleStepEnsureAttributes.Tests.ps1:355
- The test comment says the provider should be called with a $null value, but the assertions use
Should -BeNullOrEmpty, which will also pass for empty strings. To properly regression-test the original binder issue (null elements in the arguments array), assert the loggedValueis exactly$null(e.g.,Should -Be $null) for both attributes.
$callsByName['mobile'].Value | Should -BeNullOrEmpty
$callsByName['telephoneNumber'].Value | Should -BeNullOrEmpty
Code Coverage Report
|
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.
Using
EnsureAttributeswith$nullattribute values (e.g., to clearmobileortelephoneNumbervia AD's-Clear) throwsCannot bind argument to parameter 'MethodArguments' because it is null.— even when the array itself is non-null.Root cause
PowerShell's
[Mandatory]parameter binding rejects any[object[]]array that contains any$nullelement. In theEnsureAttributesfallback path, a typed[object[]]is constructed with$attrValueas the third element; when that value is$null, passing the array toInvoke-IdleProviderMethod -MethodArgumentsfails at the binder — before ever reaching the AD adapter.Changes
Invoke-IdleProviderMethod.ps1— Add[AllowNull()]to$MethodArgumentsalongside the existing[AllowEmptyCollection()], permitting arrays that carry$nullelements through parameter binding. An explicit null-reference guard is added inside the function body to distinguish the two cases: the array reference itself must never be$null(that would be a caller bug and throws a clear error), but elements within the array can be$null(valid — used to signal "clear this attribute"):Invoke-IdleStepEnsureAttributes.Tests.ps1— Regression test covering the all-null attribute case (mobile = $null,telephoneNumber = $null) through the fallback path.Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.