pulumi/pulumi-yaml

Improve non-existent field error message by checking if the field fits into the parent object

Opened this issue ยท 0 comments

Hello!

  • Vote on this issue by adding a ๐Ÿ‘ reaction
  • If you want to implement this feature, comment to let us know (we'll work with you on design, scheduling, etc.)

Issue details

After responding to pulumi/pulumi-aws#3632, I thought that my response could (and should) be automated. YAML is all about nesting, and it's pretty common to accidentally mis-nest something. Our documentation doesn't always help there.

Consider this example:

  lambda_hello_world:
    type: aws:lambda:Function
    properties:
      code:
        s3Bucket: ${s3_bucket_lambda_code.bucket}
        s3Key: helloworld.zip
      code: Cannot assign '{s3Bucket: string, s3Key: string}' to 'archive'

Both s3Bucket and s3Key are valid fields in properties. We could provide a much more helpful error message here:

      code: Cannot assign '{s3Bucket: string, s3Key: string}' to 'archive'
        Consider moving 's3Bucket: ${s3_bucket_lambda_code.bucket}' up one level to 'properties'
        Consider moving 's3Key: helloworld.zip' up one level to 'properties'

Affected area/feature

This feature is restricted to Pulumi YAML's error reporting system.