fix(Request-ADSIDHistory): 🐛 Initialize object type parameters with d…#34
fix(Request-ADSIDHistory): 🐛 Initialize object type parameters with d…#34PrzemyslawKlys merged 3 commits intomasterfrom
Conversation
…efault values * Updated `IncludeObjectType` and `ExcludeObjectType` parameters to have default empty array values. * This change ensures that the parameters are optional and improves function usability.
* Updated `ModuleVersion` in `CleanupMonster.psd1` to reflect the latest release.
There was a problem hiding this comment.
Pull request overview
This PR fixes a potential null reference error by initializing the IncludeObjectType and ExcludeObjectType parameters with empty arrays in functions that filter Active Directory objects by type.
- Adds default empty array initialization to prevent null reference errors when checking
.Countproperties - Ensures consistency between public and private functions
- Bumps module version appropriately for a patch-level bug fix
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| Private/Request-ADSIDHistory.ps1 | Initialized IncludeObjectType and ExcludeObjectType parameters with empty arrays to prevent null reference errors in filter logic |
| Public/Invoke-ADSIDHistoryCleanup.ps1 | Applied the same initialization to maintain consistency with the private function and prevent null reference errors |
| CleanupMonster.psd1 | Bumped module version from 3.1.6 to 3.1.7, appropriate for a patch-level bug fix |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| [ValidateSet('User', 'Group', 'Computer', 'msDS-ManagedServiceAccount', 'msDS-GroupManagedServiceAccount', 'ForeignSecurityPrincipal', 'Contact', 'inetOrgPerson')][string[]] $IncludeObjectType = @(), | ||
| [ValidateSet('User', 'Group', 'Computer', 'msDS-ManagedServiceAccount', 'msDS-GroupManagedServiceAccount', 'ForeignSecurityPrincipal', 'Contact', 'inetOrgPerson')][string[]] $ExcludeObjectType = @(), |
There was a problem hiding this comment.
Defaulted include types now skip every object
Setting IncludeObjectType/ExcludeObjectType to @() makes the object-type filter in Request-ADSIDHistory always execute even when the caller supplies no filters: an empty array is truthy and -notcontains evaluates to $true for any object class, so the subsequent if ($IncludeObjectType -and $IncludeObjectType -notcontains $Object.ObjectClass) branch skips every object unless the user explicitly populates IncludeObjectType. In the default configuration this prevents any SID history from being processed.
Useful? React with 👍 / 👎.
* Updated conditions for `$IncludeObjectType` and `$ExcludeObjectType` to check for count greater than zero before filtering. * Ensures that the filtering logic behaves correctly when no types are specified.
|
@codex please review again and confirm the issue is fixed |
|
Codex Review: Didn't find any major issues. 👍 ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
No description provided.