Skip to content
This repository has been archived by the owner on Jun 6, 2024. It is now read-only.

Can't enter a list of strings as JSON #137

Open
ydesai-opendoor opened this issue Jan 21, 2020 · 1 comment
Open

Can't enter a list of strings as JSON #137

ydesai-opendoor opened this issue Jan 21, 2020 · 1 comment

Comments

@ydesai-opendoor
Copy link

I am trying to add a list of strings into the Cloudflare KV Store as json via cloudworker with this command
cloudflare --kv-set CONFIG.SAMPLE_CONFIG=["92887"]. When I do this the quotes are stripped so that when I read the Config via CONFIG.get('SAMPLE_CONFIG', 'json'); I am returned [92887] which is a list of ints not strings. I tried escaping the quotes and that didn't work also.

I also tried cloudflare --kv-set CONFIG.SAMPLE_CONFIG=["test"] putting in an actual string that cannot be interpreted as an integer. When doing this reading the config via CONFIG.get('SAMPLE_CONFIG', 'json'); fails because the JSON is not parsable, and reading the value as text via CONFIG.get('SAMPLE_CONFIG', 'json'); returns "[test]" as one string which is not valid json because test is not in quotes.

Is it possible to support list of strings as a valid input into cloudflare KV Store.

@ydesai-opendoor
Copy link
Author

SyntaxError: Unexpected token e in JSON at position 2
    at JSON.parse (<anonymous>)
    at KeyValueStore.get (*s/@dollarshaveclub/cloudworker/lib/kv.js:49:37)
    at evalmachine.<anonymous>:3131:44
    at Generator.next (<anonymous>)
    at evalmachine.<anonymous>:2980:71
    at new Promise (<anonymous>)
    at __awaiter (evalmachine.<anonymous>:2976:12)
    at proxyHomesPage (evalmachine.<anonymous>:3124:12)
    at Object.handler (evalmachine.<anonymous>:3511:25)
    at evalmachine.<anonymous>:5116:51

This is the JSON Parse error when I try and call CONFIG.get('SAMPLE_CONFIG', 'json') when SAMPLE_CONFIG is set via cloudflare --kv-set CONFIG.SAMPLE_CONFIG=[\"test\"] the quotes around test I suspect are just getting stripped

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant