Skip to content

Panic when adding to a non-existing array #171

Closed

Description

@sbueringer

Hey folks,

we discovered that we get a panic if we apply the following operations to a JSON:

  • op: replace, path: "/spec/template/spec/kubeadmConfigSpec/preKubeadmCommands", value: nil
  • op: add, path: "/spec/template/spec/kubeadmConfigSpec/preKubeadmCommands/0", value: "some text"

The panic occurs here:
https://github.com/evanphx/json-patch/blob/master/v5/patch.go#L509-L513

I think the problem is that it is only checked if next is nil, but not next.raw. So then it panics in l.513 at *next.raw.

Activity

  1. added a commit that references this issue on Jan 12, 2024
    4a9dce7
  2. added a commit that references this issue on Jan 12, 2024
    3da7b27
  3. sbueringer commented on Jan 12, 2024

    @sbueringer
    Author

    Thank you very much!!

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions