Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Panic when adding to a non-existing array #171

Closed
sbueringer opened this issue Feb 6, 2023 · 1 comment
Closed

Panic when adding to a non-existing array #171

sbueringer opened this issue Feb 6, 2023 · 1 comment

Comments

@sbueringer
Copy link

sbueringer commented Feb 6, 2023

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.

@sbueringer
Copy link
Author

Thank you very much!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant