Skip to content

patch file with comments only not supported anymore in 5.2.1 (was supported in 5.1.1) #5487

@yogeek

Description

@yogeek

What happened?

I have multiple patches in a directory, some of them containing only comments (# put here your patches for the foo environment ) to serve as a guidance for end users to know what they could put inside

In kustomize 5.1.1, applying all the patches was not an issue.

Since kustomize 5.2.1, patched files with only comment in it are not supported anymore and kustomize throws an error : illegally qualifies as both an SM and JSON patch

If I remove the comment and leave the file empty, it is working again.

What did you expect to happen?

I expected patches with only comment to be supported as it was in the previous version.
I expected no regression introduced by new version of kustomize.

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

cat <<EOF >> kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
  - appset.yaml

patches:

- target:
    group: argoproj.io
    version: v1alpha1
    kind: ApplicationSet
    name: addons
  path: patches/appset-region-eu.yaml
EOF

mkdir -p patches
cat <<EOF >> patches/appset-region-eu.yaml
# add patches for EU region here if needed
EOF

worked in kustomize 5.1.1 :

$ kustomize build .
<successfully outputs the content of "appset.yaml">

error in kustomize 5.2.1 and above (same result with kustomize 5.3.0) :

$ kustomize build .
Error: trouble configuring builtin PatchTransformer with config: `
path: patches/appset-region-eu.yaml
target:
  group: argoproj.io
  kind: ApplicationSet
  name: gtp-addons
  version: v1alpha1
`: illegally qualifies as both an SM and JSON patch: [path: "patches/appset-region-eu.yaml"]

Expected output

the content of the resource

Actual output

Error: trouble configuring builtin PatchTransformer with config: `
path: patches/appset-region-eu.yaml
target:
  group: argoproj.io
  kind: ApplicationSet
  name: gtp-addons
  version: v1alpha1
`: illegally qualifies as both an SM and JSON patch: [path: "patches/appset-region-eu.yaml"]

Kustomize version

5.2.1

Operating system

Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugCategorizes issue or PR as related to a bug.lifecycle/frozenIndicates that an issue or PR should not be auto-closed due to staleness.triage/acceptedIndicates an issue or PR is ready to be actively worked on.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions