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

kopf doesn't construct JSONPatches correctly when keys include characters like ~ and / #918

Closed
sambhav opened this issue Apr 28, 2022 · 0 comments · Fixed by #919
Closed

Comments

@sambhav
Copy link
Contributor

sambhav commented Apr 28, 2022

This causes issues when trying to patch labels that contain / for eg app.kubernetes.io/created-by

See the offending lines at

result.append(JSONPatchItem(op='remove', path='/'.join(keys)))
elif len(keys) > 1 and self._original and not self._is_in_original_path(keys):
result.append(JSONPatchItem(op='add', path='/'.join(keys), value=value))
elif isinstance(value, collections.abc.Mapping) and value:
for key, val in value.items():
result.extend(self._as_json_patch(val, keys + [key]))
else:
result.append(JSONPatchItem(op='replace', path='/'.join(keys), value=value))

We need to ensure that ~ is encoded to ~0 and / to ~1

See https://datatracker.ietf.org/doc/html/rfc6901#section-3 and json-patch/json-patch-tests#42

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

Successfully merging a pull request may close this issue.

1 participant