Skip to content

Parameter existence checking in functions treats $false value as no parameter #56

@TriggerAu

Description

@TriggerAu

In the situation where there is a boolean parameter and the parameter is part of one of the checks for value before use the logic in the functions treats a false as do not do the logic

I struck this when trying to use the New-OktaUser function and passing false to the activate function to prevent an email activation.

The example/scenario is

  1. Call the New-OktaUser -Body $body -Activate $false

  2. In the function this hits this line https://github.com/okta/okta-powershell-cli/blob/b01fd0a387e16d082ca833888fba9679a63527e9/src/Okta.PowerShell/Api/OktaUserApi.ps1#L626-628

  3. This logic reads the parameter and skips setting the value in the dictionary as $Activate is false

  4. The call to the API is made and the APIs value for this when not provided is True

  5. User is created and activated and messages get sent

From the code it looks like the logic is meant to be if this parameter was provided, ,but the logic is off

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions