pulumi/changelog/pending
bors[bot] cc5eae1b0c
Merge #11673
11673: Fix illegal cast in resource constructors when secret-wrapping input arguments. r=AaronFriel a=AaronFriel

Fixes #11664 after new SDK gen. Will require an update to pulumi-aws using this branch or a new release.

Codegen for wrapping input properties as secrets performed an incorrect cast, as seen in Pulumi's AWS classic SDK.

Using the sample program and the resource constructor described in #11664 as our test case, from `pulumi-aws/sdk/v5/go/aws/secretmanager/secretVersion.go`:

```go
      func NewSecretVersion(ctx *pulumi.Context,
        name string, args *SecretVersionArgs, opts ...pulumi.ResourceOption) (*SecretVersion, error)
        if args == nil {
          return nil, errors.New("missing one or more required arguments")
        }

        if args.SecretId == nil {
          return nil, errors.New("invalid value for required argument 'SecretId'")
        }
        if args.SecretBinary != nil {
82:        args.SecretBinary = pulumi.ToSecret(args.SecretBinary).(pulumi.StringPtrOutput)
        }
        if args.SecretString != nil {
85:        args.SecretString = pulumi.ToSecret(args.SecretString).(pulumi.StringPtrOutput)
        }
```

`args.SecretBinary` is of type `pulumi.StringPtrInput` and `pulumi.ToSecret` returns `pulumi.Output` returns its input as an Output-wrapped value marked secret.

As `StringPtrInput` is an interface accepting multiple input types, the return value would be either `pulumi.StringOutput` `pulumi.StringPtrOutput`. These are both concrete types, and casting to the incorrect one would panic.

Fortunately we can cast back to the input type, as verified by building the new codegen and testing the Pulumi program in #11664.

The new codegen below converts an input type `T` to `pulumi.Output`, then casts back to `T`.

```go
      func NewSecretVersion(ctx *pulumi.Context,
        // ...
        if args.SecretBinary != nil {
82:             args.SecretBinary = pulumi.ToSecret(args.SecretBinary).(pulumi.StringPtrInput)
        }
        if args.SecretString != nil {
85:             args.SecretString = pulumi.ToSecret(args.SecretString).(pulumi.StringPtrInput)
        }
```


Co-authored-by: Aaron Friel <mayreply@aaronfriel.com>
2022-12-19 16:05:32 +00:00
..
20221031--sdk-nodejs--delegates-alias-computation-to-engine-for-node-sdk.yaml feat(sdk/nodejs): delegates alias computation to the engine 2022-12-15 17:23:31 -05:00
20221109--ci--sign-pulumi-binaries-with-cosign.yaml feat: sign pulumi binaries with cosign 2022-12-16 09:32:51 -08:00
20221116--cli--adds-a-flag-that-allows-user-to-set-the-node-label-as-the-resource-name-instead-of-the-full-urn-in-the-stack-graph.yaml Changes to stack_graph.go file and envrc file 2022-12-12 18:37:34 -08:00
20221117--cli--delete-stack-config-file-on-pulumi-remove.yaml chore: Add changelog 2022-12-13 02:34:54 +00:00
20221121--sdkgen-dotnet-nodejs--initial-implementation-of-simplified-invokes-for-dotnet-and-nodejs.yaml Initial implementation of simplified invokes for dotnet and nodejs 2022-12-16 13:39:03 +01:00
20221123--cli-config-new-package--preserve-comments.yaml chore: changelog 2022-12-10 12:29:33 -08:00
20221125--sdkgen-nodejs--fix-nodejs-sdk-when-a-component-is-using-another-component-from-the-same-schema-as-a-property.yaml Remove .NET type imports and add a test for #11467 2022-12-09 14:03:20 +01:00
20221129--sdk-nodejs--emit-closure-requires-in-global-scope-for-improved-cold-start-on-lambda.yaml docs: add changelog entry 2022-11-29 07:29:17 +00:00
20221206--cli--allow-rotating-the-encrpytion-key-for-cloud-secrets.yaml Rotate cloud secrets provider 2022-12-15 21:25:47 +00:00
20221206--sdk-dotnet--add-output-jsonserialize-using-system-text-json.yaml Add Output.JsonSerialize to dotnet sdk 2022-12-09 11:41:22 +00:00
20221206--sdk-nodejs--remove-function-serialization-code-for-out-of-suppport-nodejs-versions.yaml Remove support for old NodeJS versions from function serializer 2022-12-11 21:20:06 +00:00
20221208--sdk-python--fix-a-deadlock-on-provider-side-error-with-automation-api.yaml docs: Add changelog entry 2022-12-09 23:13:14 +01:00
20221208--sdkgen-dotnet-go-nodejs-python--do-not-generate-result-types-for-functions-with-empty-outputs.yaml Do not generate Result types for functions with empty outputs 2022-12-09 14:36:44 +01:00
20221209--sdk-go--add-jsonmarshal-to-go-sdk.yaml Add JSONMarshal to go sdk 2022-12-09 16:34:53 +00:00
20221209--sdk-nodejs--add-output-jsonstringify-using-json-stringify.yaml Add jsonStringify to nodejs sdk 2022-12-09 11:37:18 +00:00
20221209--sdk-python--add-jsondumps-to-python-sdk.yaml Add json_dumps to python sdk 2022-12-14 13:53:15 +00:00
20221212--cli-display--fixes-negative-durations-on-update-display.yaml fix negative durations in update display 2022-12-12 12:22:03 -08:00
20221212--programgen-go--Check-for-optional-Ptr-types-within-Union-types.yaml Check for optional/ Ptr types within Unions [go/programgen] 2022-12-12 15:49:20 -08:00
20221213--cli--improve-performance-of-convert-to-not-try-and-load-so-many-provider-plugins.yaml Make the PluginMapper lazy 2022-12-14 15:26:33 +00:00
20221215--backend-service--fixes-out-of-memory-issues-when-using-pulumi_optimized_checkpoint_patch-protocol-1165.yaml CHANGELOG 2022-12-15 11:52:46 -05:00
20221215--programgen--dont-panic-on-some-empty-objects.yaml Don't panic when annotating with missing objects 2022-12-15 10:20:49 +01:00
20221217--sdkgen-go--illegal-cast-in-resource-constructors-when-secret-wrapping-input-arguments.yaml fix(sdkgen/go): illegal cast in resource constructors when secret-wrapping input arguments 2022-12-16 17:27:10 -08:00
20221218--auto-dotnet-go-nodejs-python--adds-skipinstalldependencies-option-for-remote-workspaces.yaml [auto] Add SkipInstallDependencies option for remote workspaces 2022-12-19 10:27:01 -05:00