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

can't patch metadata if metadata is null #3244

Closed
5 of 6 tasks
woylie opened this issue Apr 19, 2023 · 2 comments · Fixed by ory/x#692 or #3304
Closed
5 of 6 tasks

can't patch metadata if metadata is null #3244

woylie opened this issue Apr 19, 2023 · 2 comments · Fixed by ory/x#692 or #3304
Labels
bug Something is not working.

Comments

@woylie
Copy link
Contributor

woylie commented Apr 19, 2023

Preflight checklist

Describe the bug

While #3103 now allows patching metadata in general, it is still not possible to patch metadata if the value is null. Since that is the value to which the metadata fields are set initially, there is no reliable way to atomically patch metadata public/admin.

This could be solved by:

  • applying a patch operation to an empty object if the metadata value is null
  • setting the default for the metadata columns to {} and adding a not-null constraint

Reproducing the bug

  1. create an identity with metadata_admin set to null
  2. PATCH /admin/identities/{id} with this request body:
[
  {
    "op": "replace",
    "path": "/metadata_admin/shoe_size",
    "value": 41
  }
]

This fails with the message replace operation does not apply: doc is missing path: /metadata_admin/shoe_size: missing value. The same happens with "add".

On the other hand, this:

[
  {
    "op": "add",
    "path": "/metadata_admin",
    "value": {}
  },
  {
    "op": "replace",
    "path": "/metadata_admin/shoe_size",
    "value": 41
  }
]

Will succeed the first time when the metadata value is null, but when the metadata field already has other fields, they will be removed.

Relevant log output

No response

Relevant configuration

No response

Version

0.13.0

On which operating system are you observing this issue?

macOS

In which environment are you deploying?

Docker Compose

Additional Context

The issue was reported before in #3099. A related issue was reported in #2950 and fixed in #3103.

@IchordeDionysos
Copy link
Contributor

IchordeDionysos commented Jun 6, 2023

It's not yet actually fixed, only the root cause has been fixed.
The ory/x dependency needs to be updated to the latest version in Kratos for the fix to be active.
PR: #3304

@IchordeDionysos IchordeDionysos mentioned this issue Jun 6, 2023
7 tasks
@IchordeDionysos
Copy link
Contributor

Should hopefully be fixed soon on Ory-network

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is not working.
Projects
None yet
2 participants