Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test-PodeOAVersion version value validation #1357

Closed
hrebynakha opened this issue Jul 11, 2024 · 1 comment · Fixed by #1358
Closed

Test-PodeOAVersion version value validation #1357

hrebynakha opened this issue Jul 11, 2024 · 1 comment · Fixed by #1358
Labels

Comments

@hrebynakha
Copy link

hrebynakha commented Jul 11, 2024

Describe the Bug

Bug in different powershell version, decimal value validation not works fine.

Steps To Reproduce

Steps to reproduce the behavior:
In this component file:
Pode/blob/develop/src/Public/OAComponents.ps1

function Test-PodeOAVersion

When try it use like this:
Test-PodeOAVersion -Version 3.1
got error:
Test-PodeOAVersion : Cannot validate argument on parameter 'Version'. The argument "3,1" does not belong to the set "3.1,3" specified by the ValidateSet attribute. Supply an argument that is in the set and then try the command again.

function Test-PodeOAVersion
[Parameter(Mandatory = $true)]
[ValidateSet( 3.1 , 3.0 )]
[decimal]
$Version,

Version validation shoud be changed to [int] value .

Platform

  • OS: Windows
  • Browser: [e.g. Chrome, Safari]
  • Versions:
    • Pode: 2.10.1
    • PowerShell: 5.1.22621.2506

Additional Context

This issue works only using this Powershell version (may be grate version also , i don't test ):
$PSVersionTable

Name Value


PSVersion 5.1.22621.2506
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.22621.2506
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1

For example on this powershell version it works fine

$PSVersionTable

Name Value


PSVersion 5.1.14393.6343
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.14393.6343
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1

@mdaneri
Copy link
Contributor

mdaneri commented Jul 11, 2024

I just tried with
Name Value


PSVersion 5.1.22621.3880
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.22621.3880
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1

and works fine.

You are using the Windows 11 October 2023 patch https://support.microsoft.com/en-us/topic/october-31-2023-kb5031455-os-builds-22621-2506-and-22631-2506-preview-6513c5ec-c5a2-4aaf-97f5-44c13d29e0d4
Looks like it's a bug in this specific version of PowerShell, not a Pode one.

You cannot define $Version as [int] otherwise 3.1 is not accepted. What we can do is to change it to string.
I've a branch open to fix any OpenAPI issues. I'm going to add the workaround to the branch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
2 participants