pulumi / pulumi-yaml

YAML language provider for Pulumi
Apache License 2.0
39 stars 12 forks source link

Pulumi config value automatically interpreted as Integer #415

Closed dongqiaoyang closed 1 year ago

dongqiaoyang commented 1 year ago

What happened?

The config value get automatically set as integer from string.

Pulumi version: v3.47.1

Input from CLI:

pulumi --non-interactive config set sha "123"

In the Pulumi.yaml:

configuration: sha: type: String

Error: pulumi:pulumi:Stack testing-testing running Error: config key sha cannot have conflicting types string, integer

Steps to reproduce

The config value get automatically set as integer from string.

Pulumi version: v3.48.0

Input from CLI:

pulumi --non-interactive config set sha "123"

In the Pulumi.yaml:

configuration: sha: type: String

Error: pulumi:pulumi:Stack testing-testing running Error: config key sha cannot have conflicting types string, integer

Expected Behavior

No config type error returned

Actual Behavior

Error: pulumi:pulumi:Stack testing-testing running Error: config key sha cannot have conflicting types string, integer

Output of pulumi about

No response

Additional context

No response

Contributing

Vote on this issue by adding a 👍 reaction. To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).

Frassle commented 1 year ago

Suspect config set didn't respect the project type correctly, it should of seen the type was number and saved to the settings as a number not string.

dongqiaoyang commented 1 year ago

@Frassle Current situation is that config set string like "123" gets automatically interpreted to integer by pulumi

Frassle commented 1 year ago

Ah yeh sorry my bad, got the types the wrong way round but the essence is the same. The config save didn't check against the project settings.

terekete commented 1 year ago

@Frassle - curious, when you are referring to project settings, what do you mean by that ?

Frassle commented 1 year ago
In the Pulumi.yaml:

configuration:
sha:
type: String
dongqiaoyang commented 1 year ago

@Frassle , is it an expected behavior?

sha is expected to be a string and not integer.

How comes pulumi config set sha "123" not setting the type correctly?

Frassle commented 1 year ago

Because the CLI doesn't see "123" because of how shell quotes work. We just get the string 123 (not "123") and do a best guess that it's an integer. If we didn't do this then everything would be a string.

But we now have types in the project config, so now we can do better than the above. The CLI should look at the Pulumi.yaml see that sha is of type string and then store it as a string even if the old logic goes "this looks like a number".

dongqiaoyang commented 1 year ago

@Frassle the pulumi.yaml is already set up already as sha is type string, that was the original issue.

Will this be logged at a defect from Pulumi perspective and to be fixed?

Frassle commented 1 year ago

Will this be logged at a defect from Pulumi perspective and to be fixed?

Yes I'm looking into this.

iwahbe commented 1 year ago

@Frassle It's important to note here that pathed values work differently from un-pathed values. pulumi config set sha[0] 123 generates a number.

some-program:sha:
  - 123

I think we should work to align pathed and un-pathed behavior, but its helpful to know when they diverge.

Frassle commented 1 year ago

@iwahbe yeh that would be ideal but I don't think that's actually the issue here. @dongqiaoyang I'm going to assume this is using a Pulumi yaml program given the error message and move this to that repo, I don't think this is an issue with the core engines handling of config.

dongqiaoyang commented 1 year ago

@Frassle yes it is using pulumi yaml program. a