unkey icon indicating copy to clipboard operation
unkey copied to clipboard

Gracefull Error Handling for the following payload

Open shreyanshtomar opened this issue 2 years ago • 3 comments

Preliminary Checks

  • [X] I have reviewed the documentation: https://unkey.dev/docs

  • [X] I have searched for existing issues: https://github.com/unkeyed/unkey/issues

  • [X] This issue is not a question, general help request, or anything other than a bug report directly related to Unkey. Please ask questions in our Discord community: https://unkey.dev/discord.

Reproduction / Replay Link (Optional)

No response

Description

curl --location 'https://api.unkey.dev/v1/keys'
--header 'Authorization: Bearer <TOKEN>'
--header 'Content-Type: application/json'
--data '{ "apiId": "<API_ID>", "byteLength":0 }'

Debugged this for quite sometime as why was I getting the 500 error while building Springboot (JAVA) SDK for unkey, as my code in backend was setting byteLength as 0 instead of null. Hence, the error. Just reporting it if it can be handled gracefully. Error : runtime error: slice bounds out of range [:5] with length 2 It could be something like byteLength can't be 0 (or less 2). It's working for byteLength:2 and above.

Environment

No response

shreyanshtomar avatar Nov 16 '23 17:11 shreyanshtomar

I would like to work on this issue @perkinsjr

yash37158 avatar Nov 16 '23 19:11 yash37158

@shreyanshtomar cool stuff working on the sdk. Can you link it here or maybe tag me on disc? Im shawshankkumar everywhere :)

shawshankkumar avatar Nov 16 '23 20:11 shawshankkumar

Will be fixed here, thanks for creating the issue to track it! https://github.com/unkeyed/unkey/blob/178797b7ae91327130d7299a21695c863d9abaee/apps/api/src/routes/v1_keys_createKey.ts#L49

chronark avatar Nov 16 '23 20:11 chronark