pulumi/pulumi-yaml

Improve non-existent field error message by checking if the field fits into the child 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

Building on top of #559, we currently (correctly) error when user's specify an invalid property for an object. If the invalid field specified is valid in a directly nested object, we should suggest that the user nests it.

For example:

  service:
    type: gcp:cloudrun:Service
    properties:
      location: us-central1
      template:
        containers:
          - image: "gcr.io/cloudrun/hello"
    Error: Property containers does not exist on 'gcp:cloudrun/ServiceTemplate:ServiceTemplate'
      on Pulumi.yaml line 13:
      13:         containers:
      14:           - image: "gcr.io/cloudrun/hello"
    Cannot assign '{location: string, template: {containers: List<{image: string}>}}' to 'gcp:cloudrun/service:Service':      template: Cannot assign '{containers: List<{image: string}>}' to 'gcp:cloudrun/ServiceTemplate:ServiceTemplate':
        Existing properties are: metadata, spec

We should also suggest that containers is a property of spec:

    Error: Property containers does not exist on 'gcp:cloudrun/ServiceTemplate:ServiceTemplate'
      on Pulumi.yaml line 13:
      13:         containers:
      14:           - image: "gcr.io/cloudrun/hello"
    Cannot assign '{location: string, template: {containers: List<{image: string}>}}' to 'gcp:cloudrun/service:Service':      template: Cannot assign '{containers: List<{image: string}>}' to 'gcp:cloudrun/ServiceTemplate:ServiceTemplate':
        Existing properties are: metadata, spec
        'containers' is a property of 'spec': consider nesting 'containers' under 'spec':
        ```
          spec:
            containers:
              - image: "gcr.io/cloudrun/hello"
        ```

Affected area/feature