Skip to content

fix(Request-ADSIDHistory): 🐛 Initialize object type parameters with d…#34

Merged
PrzemyslawKlys merged 3 commits intomasterfrom
FixInclude
Nov 24, 2025
Merged

fix(Request-ADSIDHistory): 🐛 Initialize object type parameters with d…#34
PrzemyslawKlys merged 3 commits intomasterfrom
FixInclude

Conversation

@PrzemyslawKlys
Copy link
Copy Markdown
Member

No description provided.

…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.
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 .Count properties
  • 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.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 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".

Comment on lines +10 to +11
[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 = @(),
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge 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.
@PrzemyslawKlys
Copy link
Copy Markdown
Member Author

@codex please review again and confirm the issue is fixed

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 👍

ℹ️ 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".

@PrzemyslawKlys PrzemyslawKlys merged commit d2dbcfd into master Nov 24, 2025
@PrzemyslawKlys PrzemyslawKlys deleted the FixInclude branch November 24, 2025 15:57
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.

2 participants