Skip to content

Strategic merge failures are unclear #5997

@carlosonunez-redhat

Description

@carlosonunez-redhat

What happened?

Trying to patch a strategic merge that's inlined in the Kustomization triggers an unable to parse SM or JSON error with no further details.

What did you expect to happen?

The error would explain why the patch failed to merge.

How can we reproduce it (as minimally and precisely as possible)?

# kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
  - configmap.yaml
patches:
  - target:
      kind: ConfigMap
      name: test
    patch: |-
      data:
        foo: quux
apiVersion: v1
kind: Config
metadata:
  name: test
data:
  foo: bar

Expected output

$: kustomize build .
Error: trouble configuring builtin PatchTransformer with config: `
patch: |-
  data:
    foo: quux
target:
  kind: ConfigMap
  name: test
`: unable to parse SM or JSON patch from [patch: "data:\n  foo: quux"]; SM error: missing Resource metadata, JSON6902 error: json: cannot unmarshal object into Go value of type jsonpatch.Patch

Actual output

$: kustomize build .
Error: trouble configuring builtin PatchTransformer with config: `
patch: |-
  data:
    foo: quux
target:
  kind: ConfigMap
  name: test
`: unable to parse SM or JSON patch from [patch: "data:\n  foo: quux"]

Kustomize version

v5.7.1-41-g88d593f22-dirty

Operating system

MacOS

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugCategorizes issue or PR as related to a bug.needs-triageIndicates an issue or PR lacks a `triage/foo` label and requires one.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions