Skip to content

Panic when adding to a non-existing array #171

@sbueringer

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions