Skip to content

defaultValue on constraints are not being evaluated #1228

@Gijsreyn

Description

@Gijsreyn

Prerequisites

  • Write a descriptive title.
  • Make sure you are able to repro it on the latest version
  • Search the existing issues.

Summary

Parameter constraints (minValue, maxValue, minLength, maxLength, allowedValues) are not being validated when parameters use their default values. Constraints are correctly validated when parameters are provided at runtime via input, but the validation is skipped entirely when a parameter falls back to its defaultValue.

Steps to reproduce

  1. Create a configuration with a parameter that has an invalid default value:
$schema: https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/config/document.json
parameters:
  port:
    type: int
    minValue: 1
    maxValue: 65535
    defaultValue: 99999  # Violates maxValue constraint
resources:
  - name: Echo Test
    type: Microsoft.DSC.Debug/Echo
    properties:
      output: "[parameters('port')]"
  1. Run the configuration WITHOUT providing parameter input:
dsc config get --file config.yaml

Expected behavior

DSC should validate the `defaultValue` (99999) against the `maxValue` constraint (65535) and raise an error:


ERROR Parameter input failure: Validation: Parameter 'port' has maximum value constraint of 65535 but is 99999

Actual behavior

The configuration runs successfully without any validation error, using the invalid default value of 99999.

Error details

Environment data

Name                           Value
----                           -----
PSVersion                      7.5.4
PSEdition                      Core
GitCommitId                    7.5.4
OS                             Microsoft Windows 10.0.26100
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Version

dsc 3.2.0-preview.7

Visuals

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions