cartographer icon indicating copy to clipboard operation
cartographer copied to clipboard

Interpolation errors should not show recursiveness in status

Open emmjohnson opened this issue 2 years ago • 0 comments

If there is an interpolation error, we show the entire trace in our error message. This will cause the message to show the same value many times (in this case 6) with no helpful context (one message with the value would do just fine).

This is what we currently see -

- conditions:
  - lastTransitionTime: "2022-04-15T17:12:17Z"
    message: |-
      unable to stamp object for resource [deployer] in supply chain [supply-chain]: failed to recursively evaluate template: failed to interpolate map value [map[deploy:[map[kapp:map[]]] fetch:[map[inline:map[paths:map[manifest.yml:---
      apiVersion: kapp.k14s.io/v1alpha1
      kind: Config
      rebaseRules:
        - path:
            - metadata
            - annotations
            - serving.knative.dev/creator
          type: copy
          sources: [new, existing]
          resourceMatchers: &matchers
            - apiVersionKindMatcher:
                apiVersion: serving.knative.dev/v1
                kind: Service
        - path:
            - metadata
            - annotations
            - serving.knative.dev/lastModifier
          type: copy
          sources: [new, existing]
          resourceMatchers: *matchers
      
      ---
      apiVersion: serving.knative.dev/v1
      kind: Service
      metadata:
        name: $(workload.metadata.name)$
      spec:
        template:
          metadata:
            annotations:
              autoscaling.knative.dev/minScale: "1"
          spec:
            serviceAccountName: cartographer-example-registry-creds-sa
            containers:
              - name: workload
                image: $(images.image.image)$
                securityContext:
                  runAsUser: 1000
      ]]]] serviceAccountName:cartographer-example-registry-creds-sa template:[map[ytt:map[]]]]]: failed to interpolate map value [[map[inline:map[paths:map[manifest.yml:---
      apiVersion: kapp.k14s.io/v1alpha1
      kind: Config
      rebaseRules:
        - path:
            - metadata
            - annotations
            - serving.knative.dev/creator
          type: copy
          sources: [new, existing]
          resourceMatchers: &matchers
            - apiVersionKindMatcher:
                apiVersion: serving.knative.dev/v1
                kind: Service
        - path:
            - metadata
            - annotations
            - serving.knative.dev/lastModifier
          type: copy
          sources: [new, existing]
          resourceMatchers: *matchers
      
      ---
      apiVersion: serving.knative.dev/v1
      kind: Service
      metadata:
        name: $(workload.metadata.name)$
      spec:
        template:
          metadata:
            annotations:
              autoscaling.knative.dev/minScale: "1"
          spec:
            serviceAccountName: cartographer-example-registry-creds-sa
            containers:
              - name: workload
                image: $(images.image.image)$
                securityContext:
                  runAsUser: 1000
      ]]]]]: failed to interpolate array value [map[inline:map[paths:map[manifest.yml:---
      apiVersion: kapp.k14s.io/v1alpha1
      kind: Config
      rebaseRules:
        - path:
            - metadata
            - annotations
            - serving.knative.dev/creator
          type: copy
          sources: [new, existing]
          resourceMatchers: &matchers
            - apiVersionKindMatcher:
                apiVersion: serving.knative.dev/v1
                kind: Service
        - path:
            - metadata
            - annotations
            - serving.knative.dev/lastModifier
          type: copy
          sources: [new, existing]
          resourceMatchers: *matchers
      
      ---
      apiVersion: serving.knative.dev/v1
      kind: Service
      metadata:
        name: $(workload.metadata.name)$
      spec:
        template:
          metadata:
            annotations:
              autoscaling.knative.dev/minScale: "1"
          spec:
            serviceAccountName: cartographer-example-registry-creds-sa
            containers:
              - name: workload
                image: $(images.image.image)$
                securityContext:
                  runAsUser: 1000
      ]]]]: failed to interpolate map value [map[paths:map[manifest.yml:---
      apiVersion: kapp.k14s.io/v1alpha1
      kind: Config
      rebaseRules:
        - path:
            - metadata
            - annotations
            - serving.knative.dev/creator
          type: copy
          sources: [new, existing]
          resourceMatchers: &matchers
            - apiVersionKindMatcher:
                apiVersion: serving.knative.dev/v1
                kind: Service
        - path:
            - metadata
            - annotations
            - serving.knative.dev/lastModifier
          type: copy
          sources: [new, existing]
          resourceMatchers: *matchers
      
      ---
      apiVersion: serving.knative.dev/v1
      kind: Service
      metadata:
        name: $(workload.metadata.name)$
      spec:
        template:
          metadata:
            annotations:
              autoscaling.knative.dev/minScale: "1"
          spec:
            serviceAccountName: cartographer-example-registry-creds-sa
            containers:
              - name: workload
                image: $(images.image.image)$
                securityContext:
                  runAsUser: 1000
      ]]]: failed to interpolate map value [map[manifest.yml:---
      apiVersion: kapp.k14s.io/v1alpha1
      kind: Config
      rebaseRules:
        - path:
            - metadata
            - annotations
            - serving.knative.dev/creator
          type: copy
          sources: [new, existing]
          resourceMatchers: &matchers
            - apiVersionKindMatcher:
                apiVersion: serving.knative.dev/v1
                kind: Service
        - path:
            - metadata
            - annotations
            - serving.knative.dev/lastModifier
          type: copy
          sources: [new, existing]
          resourceMatchers: *matchers
      
      ---
      apiVersion: serving.knative.dev/v1
      kind: Service
      metadata:
        name: $(workload.metadata.name)$
      spec:
        template:
          metadata:
            annotations:
              autoscaling.knative.dev/minScale: "1"
          spec:
            serviceAccountName: cartographer-example-registry-creds-sa
            containers:
              - name: workload
                image: $(images.image.image)$
                securityContext:
                  runAsUser: 1000
      ]]: failed to interpolate map value [---
      apiVersion: kapp.k14s.io/v1alpha1
      kind: Config
      rebaseRules:
        - path:
            - metadata
            - annotations
            - serving.knative.dev/creator
          type: copy
          sources: [new, existing]
          resourceMatchers: &matchers
            - apiVersionKindMatcher:
                apiVersion: serving.knative.dev/v1
                kind: Service
        - path:
            - metadata
            - annotations
            - serving.knative.dev/lastModifier
          type: copy
          sources: [new, existing]
          resourceMatchers: *matchers
      
      ---
      apiVersion: serving.knative.dev/v1
      kind: Service
      metadata:
        name: $(workload.metadata.name)$
      spec:
        template:
          metadata:
            annotations:
              autoscaling.knative.dev/minScale: "1"
          spec:
            serviceAccountName: cartographer-example-registry-creds-sa
            containers:
              - name: workload
                image: $(images.image.image)$
                securityContext:
                  runAsUser: 1000
      ]: failed to interpolate leaf node: interpolate tag: evaluate jsonpath: jsonpath returned empty list: images.image.image
    reason: TemplateStampFailure
    status: "False"
    type: ResourcesSubmitted

If we strip away the contents of manifest.yml we are left with -

- conditions:
  - lastTransitionTime: "2022-04-15T17:12:17Z"
    message: |-
      unable to stamp object for resource [deployer] in supply chain [supply-chain]: failed to recursively evaluate template: failed to interpolate map value [map[deploy:[map[kapp:map[]]] fetch:[map[inline:map[paths:map[manifest.yml:---
      <<template>>
      ]]]] serviceAccountName:cartographer-example-registry-creds-sa template:[map[ytt:map[]]]]]: failed to interpolate map value [[map[inline:map[paths:map[manifest.yml:---
      <<template>>
      ]]]]]: failed to interpolate array value [map[inline:map[paths:map[manifest.yml:---
      <<template>>
      ]]]]: failed to interpolate map value [map[paths:map[manifest.yml:---
      <<template>>
      ]]]: failed to interpolate map value [map[manifest.yml:---
      <<template>>
      ]]: failed to interpolate map value [---
      <<template>>
      ]: failed to interpolate leaf node: interpolate tag: evaluate jsonpath: jsonpath returned empty list: images.image.image
    reason: TemplateStampFailure
    status: "False"
    type: ResourcesSubmitted

And I think the only thing we really care about is jsonpath returned empty list: images.image.image

I would expect to see -

- conditions:
  - lastTransitionTime: "2022-04-15T17:12:17Z"
    message: |-
      unable to stamp object for resource [deployer] in supply chain [supply-chain]: failed to recursively evaluate template: failed to interpolate leaf node: interpolate tag: evaluate jsonpath: jsonpath returned empty list: images.image.image in
      apiVersion: kapp.k14s.io/v1alpha1
      kind: Config
      rebaseRules:
        - path:
            - metadata
            - annotations
            - serving.knative.dev/creator
          type: copy
          sources: [new, existing]
          resourceMatchers: &matchers
            - apiVersionKindMatcher:
                apiVersion: serving.knative.dev/v1
                kind: Service
        - path:
            - metadata
            - annotations
            - serving.knative.dev/lastModifier
          type: copy
          sources: [new, existing]
          resourceMatchers: *matchers
      
      ---
      apiVersion: serving.knative.dev/v1
      kind: Service
      metadata:
        name: $(workload.metadata.name)$
      spec:
        template:
          metadata:
            annotations:
              autoscaling.knative.dev/minScale: "1"
          spec:
            serviceAccountName: cartographer-example-registry-creds-sa
            containers:
              - name: workload
                image: $(images.image.image)$
                securityContext:
                  runAsUser: 1000

emmjohnson avatar Apr 18 '22 18:04 emmjohnson