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

TypeScript SDK: Config Decoding to Type Bug #8520

Open
rawkode opened this issue Dec 1, 2021 · 1 comment
Open

TypeScript SDK: Config Decoding to Type Bug #8520

rawkode opened this issue Dec 1, 2021 · 1 comment
Labels
kind/enhancement Improvements or new features

Comments

@rawkode
Copy link
Contributor

rawkode commented Dec 1, 2021

Hello!

  • 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)

Issue details

Pulumi doesn't error if the decoded config, from a stack.yaml, doesn't reflect the types being coerced to.

Steps to reproduce

# Stack.yaml
config:
  config-and-secrets:name: rawkode
  config-and-secrets:user:
    name: David Flanagan
    age: hello
    handles: rawkode
# index.ts
import * as pulumi from "@pulumi/pulumi";

interface MyConfig {
  name: string;
  age: number;
  handles: string[];
}

const config = new pulumi.Config();

const myConfig: MyConfig = config.requireObject<MyConfig>("user");

export const user = myConfig;

Expected: Error because YAML doesn't decode into interface type
Actual: Decodes fine:

Outputs:
    user: {
        age    : "hello"
        handles: "rawkode"
        name   : "David Flanagan"
    }
@rawkode rawkode added the kind/bug Some behavior is incorrect or out of spec label Dec 1, 2021
@rawkode rawkode changed the title TypeScript SDK: Config Decoding to Type TypeScript SDK: Config Decoding to Type Bug Dec 1, 2021
@pgavlin
Copy link
Member

pgavlin commented Dec 2, 2021

IIRC interface types have no runtime representation--they're only used by the TypeScript compiler--so I don't think that there's any way for us to actually check this when decoding. I agree that this is surprising, but I'm not sure how we can do better without some pretty substantial changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement Improvements or new features
Projects
None yet
Development

No branches or pull requests

2 participants