pulumi / pulumi-linode

Linode resource provider for Pulumi
Apache License 2.0
27 stars 7 forks source link

Instance stackscriptId type error #281

Open jchook opened 1 year ago

jchook commented 1 year ago

What happened?

Type 'Output<string>' is not assignable to type 'number | Promise<number> | OutputInstance<number> | undefined'.
  Type 'Output<string>' is not assignable to type 'OutputInstance<number>'.
    Types of property 'apply' are incompatible.
      Type '{ <U>(func: (t: string) => Promise<U>): Output<U>; <U>(func: (t: string) => OutputInstance<U>): Output<U>; <U>(func: (t: string) => U): Output<...>; }' is not assignable to type '{ <U>(func: (t: number) => Promise<U>): Output<U>; <U>(func: (t: number) => OutputInstance<U>): Output<U>; <U>(func: (t: number) => U): Output<...>; }'.
        Types of parameters 'func' and 'func' are incompatible.
          Types of parameters 't' and 't' are incompatible.
            Type 'string' is not assignable to type 'number'. (tsserver 2322)

Expected Behavior

No type error.

Steps to reproduce

import * as linode from "@pulumi/linode";

export const appStackScript = new linode.StackScript("appStackScript", {
  description: "My App StackScript",
  label: "appStackScript",
  images: ["linode/debian11"],
  isPublic: false,
  script: '# ...',
});

export const app1 = new linode.Instance("app1", {
  image: "linode/debian11",
  label: "app1",
  region: "us-east",
  type: "g6-nanode-1",
  stackscriptId: appStackScript.id, // Type error here
});

Output of pulumi about

CLI          
Version      3.46.1-dev.0
Go Version   go1.19.2
Go Compiler  gc

Plugins
NAME    VERSION
linode  3.12.0
nodejs  unknown

Host     
OS       void
Version  
Arch     x86_64

This project is written in nodejs: executable='/home/jchook/.local/opt/n/bin/node' version='v16.19.1'

Current Stack: dev

Found no resources associated with dev

Found no pending operations associated with dev

Backend        
Name           pulumi.com
URL            https://app.pulumi.com/jchook
User           jchook
Organizations  jchook

Dependencies:
NAME            VERSION
@types/node     16.18.31
@pulumi/linode  3.12.0
@pulumi/pulumi  3.68.0

Pulumi locates its logs in /tmp by default

Additional context

I would like to create a StackScript and then apply it to an instance.

I don't fully understand technical details of the issue, but this seems like a bug to me.

Potential workaround:

export const app1 = new linode.Instance("app1", {
  // ...
  stackscriptId: appStackScript.id.apply(id => parseInt(id)),
}

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

aq17 commented 1 year ago

Hi @jchook , thanks for opening the issue. The workaround you suggested is correct – the issue is with how we are generating our diff strategy. Since network.id is unknown during preview, the apply also generates an unknown value. We are tracking this issue here.

mjeffryes commented 1 week ago

Unfortunately, it looks like this issue hasn't seen any updates in a while. If you're still encountering this problem, could you leave a quick comment to let us know so we can prioritize it? (Commenting will bump it back into our triage queue.)