pulumi / pulumi-yaml

YAML language provider for Pulumi
Apache License 2.0
38 stars 11 forks source link

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

Open iwahbe opened 3 months ago

iwahbe commented 3 months ago

Hello!

Issue details

After responding to https://github.com/pulumi/pulumi-aws/issues/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.