unkeyed / unkey

Open source API management platform
https://go.unkey.com
Other
2.84k stars 283 forks source link

[KEY-102] Updating a key produces inconsistent results #227

Closed Jonxslays closed 1 year ago

Jonxslays commented 1 year ago

Describe the bug

I have noticed when updating the same key multiple times, the properties of the key are not consistent.

To Reproduce

curl -X POST "https://api.unkey.dev/v1/keys" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer unkey_XXX" \
  -d '{ "apiId": "api_XXX", "ownerId": "test_owner" }'
curl -X PUT "https://api.unkey.dev/v1/keys/key_XXX" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer unkey_XXX" \
  -d '{ "ownerId": null }'
curl -X PUT "https://api.unkey.dev/v1/keys/key_XXX" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer unkey_XXX" \
  -d '{ "name": "test_name" }'

Expected Behavior

The key will have no ownerId as we removed it previously.

Screenshot/ Video

No response

Additional context

I also noticed that the expires field behaves the same as the ownerId field. I haven't done much research into other fields that may be affected - these we're just the ones I noticed when testing the update key method for the new WIP Rust SDK.

KEY-102

perkinsjr commented 1 year ago

Hey @Jonxslays thanks for reporting this with reproduction steps.

I'll take a look tomorrow

chronark commented 1 year ago

writing a testcase for this right now, awesome report <3

chronark commented 1 year ago

Fixed, thanks