Skip to content

Better error message when patch is the wrong type? #5113

Open

Description

@roy-work

What happened?

If I attempt the supplied patch, kustomize errors.

What did you expect to happen?

The patch is applied, or, if not, a usable diagnostic as to what is wrong with the input given.

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

# kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
  - argocd.yaml
patchesJson6902:
  - target:
      group: rbac.authorization.k8s.io
      version: v1
      kind: ClusterRole
      name: argocd-server
    patch:
      - op: add
        path: "/rules/3/verbs/2"
        value: "update"
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  labels:
    app.kubernetes.io/component: server
    app.kubernetes.io/name: argocd-server
    app.kubernetes.io/part-of: argocd
  name: argocd-server
rules:
- apiGroups:
  - '*'
  resources:
  - '*'
  verbs:
  - delete
  - get
  - patch
- apiGroups:
  - ""
  resources:
  - events
  verbs:
  - list
- apiGroups:
  - ""
  resources:
  - pods
  - pods/log
  verbs:
  - get
- apiGroups:
  - argoproj.io
  resources:
  - applications
  verbs:
  - get
  - list
  - watch

Expected output

#[rest same as before]
- apiGroups:
  - argoproj.io
  resources:
  - applications
  verbs:
  - get
  - list
  - update
  - watch

Actual output

» kustomize build .
Error: invalid Kustomization: json: cannot unmarshal array into Go struct field Patch.patchesJson6902.patch of type string

Kustomize version

v5.0.1

Operating system

MacOS

Activity

  1. added
    kind/bugCategorizes issue or PR as related to a bug.
    on Mar 29, 2023
  2. added
    needs-triageIndicates an issue or PR lacks a `triage/foo` label and requires one.
    on Mar 29, 2023
  3. roy-work commented on Mar 29, 2023

    @roy-work
    Author

    Okay, this is partial user-error, but a.) this is really hard to see and b.) the error message could be loads more helpful in pointing me in the right direction here.

    This:

        patch:

    needs to be,

        patch: |

    Kustomize requires the entire JSON patch to be double-encoded …

  4. changed the title [-]Cannot add to array?[/-] [+]Better error message when patch is the wrong type?[/+] on Mar 29, 2023
  5. koba1t commented on Apr 5, 2023

    @koba1t
    Member

    I think patchesJson6902.[].patch requires the format of yaml string in multi-line literal is a reasonable reason.
    Because I think patchesJson6902.[].patch is just converted for Yaml format of json6902.
    https://kubectl.docs.kubernetes.io/references/kustomize/kustomization/patchesjson6902/

    But I agree your opinion with be a better error message.
    /triage accepted

  6. added
    triage/acceptedIndicates an issue or PR is ready to be actively worked on.
    and removed
    needs-triageIndicates an issue or PR lacks a `triage/foo` label and requires one.
    on Apr 5, 2023
  7. k8s-triage-robot commented on Apr 4, 2024

    @k8s-triage-robot

    This issue has not been updated in over 1 year, and should be re-triaged.

    You can:

    • Confirm that this issue is still relevant with /triage accepted (org members only)
    • Close this issue with /close

    For more details on the triage process, see https://www.kubernetes.dev/docs/guide/issue-triage/

    /remove-triage accepted

  8. added
    needs-triageIndicates an issue or PR lacks a `triage/foo` label and requires one.
    and removed
    triage/acceptedIndicates an issue or PR is ready to be actively worked on.
    on Apr 4, 2024
  9. k8s-triage-robot commented on Jul 3, 2024

    @k8s-triage-robot

    The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

    This bot triages un-triaged issues according to the following rules:

    • After 90d of inactivity, lifecycle/stale is applied
    • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
    • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

    You can:

    • Mark this issue as fresh with /remove-lifecycle stale
    • Close this issue with /close
    • Offer to help out with Issue Triage

    Please send feedback to sig-contributor-experience at kubernetes/community.

    /lifecycle stale

  10. added
    lifecycle/staleDenotes an issue or PR has remained open with no activity and has become stale.
    on Jul 3, 2024
  11. k8s-triage-robot commented on Aug 2, 2024

    @k8s-triage-robot

    The Kubernetes project currently lacks enough active contributors to adequately respond to all issues.

    This bot triages un-triaged issues according to the following rules:

    • After 90d of inactivity, lifecycle/stale is applied
    • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
    • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

    You can:

    • Mark this issue as fresh with /remove-lifecycle rotten
    • Close this issue with /close
    • Offer to help out with Issue Triage

    Please send feedback to sig-contributor-experience at kubernetes/community.

    /lifecycle rotten

  12. added
    lifecycle/rottenDenotes an issue or PR that has aged beyond stale and will be auto-closed.
    and removed
    lifecycle/staleDenotes an issue or PR has remained open with no activity and has become stale.
    on Aug 2, 2024
  13. k8s-triage-robot commented on Sep 1, 2024

    @k8s-triage-robot

    The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

    This bot triages issues according to the following rules:

    • After 90d of inactivity, lifecycle/stale is applied
    • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
    • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

    You can:

    • Reopen this issue with /reopen
    • Mark this issue as fresh with /remove-lifecycle rotten
    • Offer to help out with Issue Triage

    Please send feedback to sig-contributor-experience at kubernetes/community.

    /close not-planned

  14. k8s-ci-robot commented on Sep 1, 2024

    @k8s-ci-robot
    Contributor

    @k8s-triage-robot: You can't close an active issue/PR unless you authored it or you are a collaborator.

    Details

    In response to this:

    The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

    This bot triages issues according to the following rules:

    • After 90d of inactivity, lifecycle/stale is applied
    • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
    • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

    You can:

    • Reopen this issue with /reopen
    • Mark this issue as fresh with /remove-lifecycle rotten
    • Offer to help out with Issue Triage

    Please send feedback to sig-contributor-experience at kubernetes/community.

    /close not-planned

    Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

  15. koba1t commented on Sep 3, 2024

    @koba1t
    Member

    /lifecycle frozen

  16. added
    lifecycle/frozenIndicates that an issue or PR should not be auto-closed due to staleness.
    and removed
    lifecycle/rottenDenotes an issue or PR that has aged beyond stale and will be auto-closed.
    on Sep 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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.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