pulumi-aws icon indicating copy to clipboard operation
pulumi-aws copied to clipboard

Resource reads with errors obfuscate the actual error

Open joeduffy opened this issue 2 years ago • 2 comments
trafficstars

Attempting to read a resource that leads to an error results in an ugly Go formatting error:

error reading S3 Bucket (not-my-bucket):
    %!w(*s3err.RequestFailure=&{0xc003f7c1c0 V+DqRMrNowWfLE8wXzMX5gJBRS+aZS5Q0u3HUK7uW9R5NfZbSWcR9VZtqG+fOQu9239yqLd5JSw=})

I assume we are trying to format the s3err.RequestFailure error struct in this example as a string or something.

I initially hit this with pulumi import:

pulumi import 'aws:s3/bucket:Bucket' my-bucket3 not-my-bucket

But then was able to reproduce with get methods too:

const bucket3 = aws.s3.Bucket.get("my-bucket3", "not-my-bucket");

Given the error message and the commonality between these two, I assume this error is coming from the bridge's read method.

joeduffy avatar May 31 '23 19:05 joeduffy

Thanks for filing this, Joe! We'll take a look.

guineveresaenger avatar Jun 02 '23 18:06 guineveresaenger

Update: I dug into this and the error is indeed wrapped in the Read() method. It occurs during the new state refresh call and is passed along from TF.

However, this bug happens only on the the AWS provider, which got me down a bit of a rabbit hole wondering if we're parsing AWS errors incorrectly, perhaps a bug in the provider..

The engine replies with:

I0606 15:45:38.743522   29662 log.go:80] provider received rpc error `Unknown`: `refreshing urn:pulumi:dev::tfbridge-1170::aws:s3/bucket:Bucket::my-bucket3: 1 error occurred:
	* error reading S3 Bucket (not-my-bucket): %!w(*s3err.RequestFailure=&{0xc003b2b9c0 OSv2DbvJrHbkJfFZgDIlFwpnYWna7+1/Yt4pW6nAFwe419X+sjlGcV/lrjv3+hwoq0fPkT1jxJM=})
`
I0606 15:45:38.743557   29662 log.go:80] rpc error kind `Unknown` may not be recoverable

But then I further learned that this error output only happens on the Bucket resource and is likely an incarnation of this upstream issue.

Compare the lovely output of apiGatewayKey:

    I0606 16:05:45.410394   32616 provider.go:919] tf.Provider[aws].Read(this_key_is_bogus, urn:pulumi:dev::tfbridge-1170::aws:apigateway/apiKey:ApiKey::my_key/aws_api_gateway_api_key) executing
    I0606 16:05:45.410466   32616 provider.go:935] aws_api_gateway_api_key has TF Importer

    error: preview failed

  aws:apigateway:ApiKey (my_key):
    error: Preview failed: resource 'this_key_is_bogus' does not exist

I am going to move this pug to pulumi-aws and mark it as blocked upstream.

guineveresaenger avatar Jun 06 '23 23:06 guineveresaenger

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

const bucket3 = aws.s3.Bucket.get("my-bucket3", "not-my-bucket-seriously-no-bucket");
anton@anton-mbp-m3> pulumi up --yes              
Previewing update (dev)

View in Browser (Ctrl+O): https://app.pulumi.com/anton-pulumi-corp/aws-2551/dev/previews/32a2a486-7579-44c9-91fc-7c23f48bec64

     Type                 Name          Plan       Info
 +   pulumi:pulumi:Stack  aws-2551-dev  create     1 error
     └─ aws:s3:Bucket     my-bucket3               1 error

Diagnostics:
  aws:s3:Bucket (my-bucket3):
    error: Preview failed: resource 'not-my-bucket-seriously-no-bucket' does not exist

  pulumi:pulumi:Stack (aws-2551-dev):
    error: preview failed

Looks like this got better on latest.

CLI          
Version      3.130.0
Go Version   go1.22.6
Go Compiler  gc

Plugins
KIND      NAME    VERSION
resource  aws     6.51.1
resource  awsx    2.14.0
resource  docker  4.5.5
resource  docker  3.6.1
language  nodejs  unknown

Host     
OS       darwin
Version  14.6.1
Arch     arm64

This project is written in nodejs: executable='/Users/anton/bin/node' version='v18.18.2'

Current Stack: anton-pulumi-corp/aws-2551/dev

Found no resources associated with dev

Found no pending operations associated with dev

Backend        
Name           pulumi.com
URL            https://app.pulumi.com/anton-pulumi-corp
User           anton-pulumi-corp
Organizations  anton-pulumi-corp, moolumi, demo, pulumi
Token type     personal

Dependencies:
NAME            VERSION
@pulumi/pulumi  3.132.0
@types/node     18.19.50
typescript      5.6.2
@pulumi/aws     6.51.1
@pulumi/awsx    2.14.0

Pulumi locates its logs in /var/folders/gd/3ncjb1lj5ljgk8xl5ssn_gvc0000gn/T/com.apple.shortcuts.mac-helper// by default

t0yv0 avatar Sep 13 '24 20:09 t0yv0