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

Bug: Parameters default value mismatch it's type #170

Open
2 of 4 tasks
Kylmakalle opened this issue Dec 9, 2022 · 2 comments
Open
2 of 4 tasks

Bug: Parameters default value mismatch it's type #170

Kylmakalle opened this issue Dec 9, 2022 · 2 comments
Labels
bug Something isn't working

Comments

@Kylmakalle
Copy link

Kylmakalle commented Dec 9, 2022

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

CustomParameter generates an entry where default parameter is not quoted. That leads to type mismatch in result YAML, since some defaults like true, on, and off can be treated as booleans instead of strings.

new CircleCI.parameters.CustomParameter(
    'some_value',
    CircleCI.mapping.ParameterSubtype.STRING,
    "OFF"
)
parameters:
     some_value:
        type: string
        default: OFF

image

Config is not valid

% circleci config validate config.yml 

Error: Error in definition of command 'some-command'
Parameter error: default value of parameter 'some_value' is 'false' (type boolean): expected type string

Minimum reproduction code

https://gist.github.com/Kylmakalle/22f2c6eae2bd09758a70be2510284b33

Expected behavior

Any default provided value is "quoted" properly and aligns with parameter type.

CircleCI Config SDK version

0.12.0

Node.js version

19.0.0

In which operating systems have you tested?

  • macOS
  • Windows
  • Linux
@Kylmakalle Kylmakalle added the bug Something isn't working label Dec 9, 2022
@KyleTryon
Copy link
Contributor

Good catch, YAML is going to make that one difficult for us. I think the main issue will be we are using a YAML parser and don't actually have a way of informing the parser to treat this value specifically as part of a string without writing some kind of custom validation library.

Was this a blocking issue or were you able to work around using a boolean or another string value?

@Kylmakalle
Copy link
Author

I believe it's possible to tweak a YAML parser. See eemeli/yaml#391

Talking about a workaround, we can add a prefix "_OFF" and cut it using different software

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants