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

Fix panic when environment uses computed values #414

Merged
merged 2 commits into from
Sep 25, 2024
Merged

Conversation

seanyeh
Copy link
Contributor

@seanyeh seanyeh commented Sep 23, 2024

Fixes #411

This is related to #399

Example repro program:

import * as pulumi from "@pulumi/pulumi";
import * as service from "@pulumi/pulumiservice";
import * as aws from "@pulumi/aws";

const org = "big-org";
const bucket = new aws.s3.Bucket("myBucket", {
    bucket: "syeh-panic-test",
    acl: "private",
});

const envDef = pulumi.interpolate`values:
  myKey1: "${bucket.arn}"`;
const envAsset = envDef.apply(x => new pulumi.asset.StringAsset(x));

const environment = new service.Environment("panic", {
  organization: org,
  project: "abc",
  name: "panic",
  yaml: envAsset,
})

@seanyeh seanyeh requested a review from a team September 23, 2024 15:27
@seanyeh seanyeh marked this pull request as ready for review September 23, 2024 15:27
yamlBytes, err := getBytesFromAsset(inputMap["yaml"].AssetValue())
if err != nil {
return nil, err
yamlBytes := []byte{}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm... does this mean there will be no yamlBytes if it's computed? Or does this only affect Check and the resolved value of environment.yaml is still correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This only affects Check. I have confirmed the resolved value is still correct (I'm assuming that it's ok to not have computed values during Check?)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The purpose of this Check is to take the string value of the yaml and put that into state, so there's always a string value to compare against. In this case, when it's computed, it'll result in yaml being empty in state. So next time there's an update, there will be a diff because there is no value for yaml. You can test this by adding an example test similar to in https://github.com/pulumi/pulumi-pulumiservice/pull/391/files

We'll need a way to get the string value even out of the computed property I think.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Computed/unknown values will only appear during a preview, so I think that this will be okay. We'll re-run the Check during the update, at which point all values will be known.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Though I do think I'd do this slightly differently--instead of checking IsAsset I'd check for !IsComputed.

Copy link
Member

@pgavlin pgavlin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we add a test for this (do we have tests for the provider in here in general)?

@seanyeh seanyeh merged commit b011017 into main Sep 25, 2024
13 checks passed
@seanyeh seanyeh deleted the syeh/fix-env-panic branch September 25, 2024 19:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

panic in pulumiservice.Environment.yaml v0.26
3 participants