-
Notifications
You must be signed in to change notification settings - Fork 607
Description
Preliminary Checks
-
I have reviewed the documentation: https://unkey.com/docs
-
I have searched for existing issues: https://github.com/unkeyed/unkey/issues
-
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.com/discord.
Reproduction / Replay Link (Optional)
No response
Issue Summary
When you have the enterprise plan, you have the function to allow IP Whitelisting. This can be done by inputting a list of CSV ips OR newline-separated ips.
Those IP's are then stored as a csv in the Database.
The issue is that the API tries to JSON parse this, which doesn't work as it's not a JSON string but a CSV, you have the function to allow IP Whitelisting. This can be done by inputting a list of CSV ips OR newline-separated ips
2024/10/12 19:18:44 error: {"error":{"code":"INTERNAL_SERVER_ERROR","docs":"https://unkey.dev/docs/api-reference/errors/code/INTERNAL_SERVER_ERROR","message":"Unexpected non-whitespace character after JSON at position 5 (line 1 column 6)","requestId":"req_3UhrGthbDURT4EZhkxZ7oriXsxdQ"}}
Steps to Reproduce
- Enable the enterprise plan in the db
- Visit the API settings and set some IP Whitelist
- When testing locally be sure to set a IP or comment out the whole part in apps/api/src/pkg/keys/service.ts

You can then call the verify key method as normal and see that you are getting a 500 error.
Expected behavior
To avoid getting a 500 error and the IP whitelist to work correctly.
So either the IP Whitelist has to be stored as a JSON array string or the API code has to be adjusted in order to parse csv.
Question:
Do the currently non-deleted APIs with IP whitelisting enable have everything stored as CSV or JSON?
If it's all CSV, it would be easier to adjust the API; otherwise, a script is needed to backfill from JSON to CSV or CSV to JSON.
Other information
No response
Screenshots
No response
Version info
Irrelevant