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

Error: Unexpected struct type. #2962

Closed
lukehoban opened this issue Jul 19, 2019 · 7 comments · Fixed by #3069
Closed

Error: Unexpected struct type. #2962

lukehoban opened this issue Jul 19, 2019 · 7 comments · Fixed by #3069
Assignees
Labels
kind/bug Some behavior is incorrect or out of spec
Milestone

Comments

@lukehoban
Copy link
Member

When updating from this:

  • @pulumi/pulumi: 0.17.12
  • @pulumi/kubernetes: 0.23.1
  • @pulumi/gcp: 0.18.5

To this (only updating @pulumi/pulumi):

  • @pulumi/pulumi: 0.17.23
  • @pulumi/kubernetes: 0.23.1
  • @pulumi/gcp: 0.18.5

A user hit this:

[2019-07-19T20:14:14Z] Error: Unexpected struct type.
[2019-07-19T20:14:14Z]     at Function.proto.google.protobuf.Value.fromJavaScript (/buildkite/builds/buildkite-agent-7c8595b96c-lcr84-1/acmecorp/deploy-acmecorp-dogfood-k8s/node_modules/google-protobuf/google/protobuf/struct_pb.js:840:13)
[2019-07-19T20:14:14Z]     at Function.proto.google.protobuf.Struct.fromJavaScript (/buildkite/builds/buildkite-agent-7c8595b96c-lcr84-1/acmecorp/deploy-acmecorp-dogfood-k8s/node_modules/google-protobuf/google/protobuf/struct_pb.js:906:51)
[2019-07-19T20:14:14Z]     at Function.proto.google.protobuf.Value.fromJavaScript (/buildkite/builds/buildkite-agent-7c8595b96c-lcr84-1/acmecorp/deploy-acmecorp-dogfood-k8s/node_modules/google-protobuf/google/protobuf/struct_pb.js:836:55)
[2019-07-19T20:14:14Z]     at Function.proto.google.protobuf.Struct.fromJavaScript (/buildkite/builds/buildkite-agent-7c8595b96c-lcr84-1/acmecorp/deploy-acmecorp-dogfood-k8s/node_modules/google-protobuf/google/protobuf/struct_pb.js:906:51)
[2019-07-19T20:14:14Z]     at Function.proto.google.protobuf.Value.fromJavaScript (/buildkite/builds/buildkite-agent-7c8595b96c-lcr84-1/acmecorp/deploy-acmecorp-dogfood-k8s/node_modules/google-protobuf/google/protobuf/struct_pb.js:836:55)
[2019-07-19T20:14:14Z]     at Function.proto.google.protobuf.Struct.fromJavaScript (/buildkite/builds/buildkite-agent-7c8595b96c-lcr84-1/acmecorp/deploy-acmecorp-dogfood-k8s/node_modules/google-protobuf/google/protobuf/struct_pb.js:906:51)
[2019-07-19T20:14:14Z]     at Object.<anonymous> (/buildkite/builds/buildkite-agent-7c8595b96c-lcr84-1/acmecorp/deploy-acmecorp-dogfood-k8s/node_modules/@pulumi/pulumi/runtime/resource.js:409:43)
[2019-07-19T20:14:14Z]     at Generator.next (<anonymous>)
[2019-07-19T20:14:14Z]     at fulfilled (/buildkite/builds/buildkite-agent-7c8595b96c-lcr84-1/acmecorp/deploy-acmecorp-dogfood-k8s/node_modules/@pulumi/pulumi/runtime/resource.js:17:58)�[0m

They were able to solve this by also updating @pulumi/gcp and @pulumi/kubernetes - to this:

  • @pulumi/pulumi: 0.17.23
  • @pulumi/kubernetes: 0.25.2
  • @pulumi/gcp: 0.18.13

There is no detail in the logs to identify what resource triggered this error.

@ameier38
Copy link

Updating to the latest pulumi broke my project and kept causing this error but I was able to fix it by removing all references to pulumi.secret.

Checked on both Windows and Ubuntu 18.04 (WSL)

pulumi version
v0.17.24

package-lock.json:

        "@pulumi/gcp": {
            "version": "0.18.13",
            "resolved": "https://registry.npmjs.org/@pulumi/gcp/-/gcp-0.18.13.tgz",
            "integrity": "sha512-V/62AjBBY8+xDDCFYfFdBVIr3ipqNXoJ87rMHVrHak55oDfvDuIXpNUsMJ2SKoDGtGik2MkkK8visCu0PYBxLQ==",
            "requires": {
                "@pulumi/pulumi": "^0.17.8",
                "@types/express": "^4.16.0",
                "read-package-json": "^2.0.13"
            }
        },
        "@pulumi/kubernetes": {
            "version": "0.25.2",
            "resolved": "https://registry.npmjs.org/@pulumi/kubernetes/-/kubernetes-0.25.2.tgz",
            "integrity": "sha512-f/hRxbN+HCjY1ZU8jOBpB5wajhs2+nYTH7tc19edphpRBDcZP7RI4VFjOGNyDz+HM51M1AErf5yfsr85qzVbBw==",
            "requires": {
                "@pulumi/pulumi": "^0.17.18",
                "@types/glob": "^5.0.35",
                "@types/js-yaml": "^3.11.2",
                "@types/node-fetch": "^2.1.4",
                "@types/tmp": "^0.0.33",
                "glob": "^7.1.2",
                "js-yaml": "^3.12.0",
                "node-fetch": "^2.3.0",
                "shell-quote": "^1.6.1",
                "tmp": "^0.0.33"
            }
        },
        "@pulumi/pulumi": {
            "version": "0.17.25",
            "resolved": "https://registry.npmjs.org/@pulumi/pulumi/-/pulumi-0.17.25.tgz",
            "integrity": "sha512-BalQpFG2T3gxiI5luzu/sleNBfe5AOt9fjRihO6fOC06V241iBiBfO/Ez17cC4aj5SLtGtU+lk/iRv++wzhDJQ==",
            "requires": {
                "@pulumi/query": "^0.3.0",
                "deasync": "^0.1.15",
                "google-protobuf": "^3.5.0",
                "grpc": "1.21.1",
                "minimist": "^1.2.0",
                "normalize-package-data": "^2.4.0",
                "protobufjs": "^6.8.6",
                "read-package-tree": "^5.3.1",
                "require-from-string": "^2.0.1",
                "semver": "^6.1.0",
                "source-map-support": "^0.4.16",
                "ts-node": "^7.0.0",
                "typescript": "^3.0.0",
                "upath": "^1.1.0"
            }
        },

@lukehoban lukehoban added this to the 0.25 milestone Jul 22, 2019
@lukehoban lukehoban added the kind/bug Some behavior is incorrect or out of spec label Jul 22, 2019
@pgavlin
Copy link
Member

pgavlin commented Aug 1, 2019

I have been unable to reproduce this issue, so I'm going to close it out for now. We can re-open if it crops up again.

@pgavlin pgavlin closed this as completed Aug 1, 2019
@jesus-curiel
Copy link

jesus-curiel commented Aug 9, 2019

Im experiencing the same issue when trying to output a kubeconfig string.
I was able to reproduce it with a simpler scenario (If I combine an output with a secret in the apply call):

Im running: v0.17.28

{
    "name": "typescript",
    "devDependencies": {
        "@types/node": "latest"
    },
    "dependencies": {
        "@pulumi/gcp": "^0.18.15",
        "@pulumi/kubernetes": "^0.25.6",
        "@pulumi/pulumi": "^0.17.28"
    }
}

index.ts

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

const bucket = new gcp.storage.Bucket("my-bucket");

export const example = pulumi
    .all([
      bucket.name,
      pulumi.secret('mysecret')
    ]).apply(([ a, b ]) => {
      return `${a}.${b}`;
    });

This is the error:

Previewing update (dev):

     Type                   Name       Plan       Info
 +   pulumi:pulumi:Stack    test-dev   create     1 error; 8 messages
 +   └─ gcp:storage:Bucket  my-bucket  create     
 
Diagnostics:
  pulumi:pulumi:Stack (test-dev):
    Error: Unexpected struct type.
        at Function.proto.google.protobuf.Value.fromJavaScript (/Users/jesus/www/pulumi/node_modules/google-protobuf/google/protobuf/struct_pb.js:846:13)
        at Function.proto.google.protobuf.Struct.fromJavaScript (/Users/jesus/www/pulumi/node_modules/google-protobuf/google/protobuf/struct_pb.js:912:51)
        at Function.proto.google.protobuf.Value.fromJavaScript (/Users/jesus/www/pulumi/node_modules/google-protobuf/google/protobuf/struct_pb.js:842:55)
        at Function.proto.google.protobuf.Struct.fromJavaScript (/Users/jesus/www/pulumi/node_modules/google-protobuf/google/protobuf/struct_pb.js:912:51)
        at Object.<anonymous> (/Users/jesus/www/pulumi/node_modules/@pulumi/pulumi/runtime/resource.js:409:43)
        at Generator.next (<anonymous>)
        at fulfilled (/Users/jesus/www/pulumi/node_modules/@pulumi/pulumi/runtime/resource.js:17:58)
 
    error: Running program '/Users/jesus/www/pulumi' failed with an unhandled exception:
    Error: Unexpected struct type.
        at Function.proto.google.protobuf.Value.fromJavaScript (/Users/jesus/www/pulumi/node_modules/google-protobuf/google/protobuf/struct_pb.js:846:13)
        at Function.proto.google.protobuf.Struct.fromJavaScript (/Users/jesus/www/pulumi/node_modules/google-protobuf/google/protobuf/struct_pb.js:912:51)
        at Function.proto.google.protobuf.Value.fromJavaScript (/Users/jesus/www/pulumi/node_modules/google-protobuf/google/protobuf/struct_pb.js:842:55)
        at Function.proto.google.protobuf.Struct.fromJavaScript (/Users/jesus/www/pulumi/node_modules/google-protobuf/google/protobuf/struct_pb.js:912:51)
        at Object.<anonymous> (/Users/jesus/www/pulumi/node_modules/@pulumi/pulumi/runtime/resource.js:409:43)
        at Generator.next (<anonymous>)
        at fulfilled (/Users/jesus/www/pulumi/node_modules/@pulumi/pulumi/runtime/resource.js:17:58)

@lukehoban lukehoban reopened this Aug 9, 2019
@lukehoban
Copy link
Member Author

I see the same results as @jesus-curiel with that same example on latest packages.

This only happens on the initial preview though. If I pulumi up --skip-preview I do not get the error, and after successfully deploying, a future pulumi up also succeeds.

The error is in registerResourceOutputs, and is triggered by an attempt to pass the following object to google.protobuf.Struct.fromJavaScript:

  { example:
       { '4dabf18193072939515e22adb298388d': '1b47061264138c4ac30d75fd1eb44270',
         value: undefined } }

@ides15
Copy link

ides15 commented Jun 15, 2021

I was having an issue (JavaScript) with Struct.fromJavaScript and this issue kept coming up on Google. I answered a related StackOverflow question on my findings to this problem: https://stackoverflow.com/a/67990891/4853208

@kay-is
Copy link

kay-is commented Jul 23, 2021

I had the same problem.

It was related to all the provider methods that returned an outs.

After I returned ...inputs as part of the outs in my create method, it worked.

The same goes for ...news as part of the outs in my update method.

@SamuelGarrattIqa
Copy link

SamuelGarrattIqa commented Aug 18, 2021

For me this seem to happen on update when of my values was undefined.

When the key had a value it worked

E.g., I had the update method returning

return Promise.resolve({
  outs: {
      myKey: undefined, // It worked out as undefined in a particular scenario
      value: {
          body // response body of update call
      }
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Some behavior is incorrect or out of spec
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants