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

unclear what --json does when running ftl config set #3408

Closed
mistermoe opened this issue Nov 15, 2024 · 2 comments · Fixed by #3782
Closed

unclear what --json does when running ftl config set #3408

mistermoe opened this issue Nov 15, 2024 · 2 comments · Fixed by #3782
Labels
next Work that will be be picked up next P3

Comments

@mistermoe
Copy link
Collaborator

Repro

❯ ftl config set --json echo.default '{ "name": "beepboop"  }'
ftl: error: unknown: JSON validation failed: default has wrong type, expected String found map[string]interface {}
❯ ftl config set --json echo.default "{\"name\": \"beepboop\"}"
ftl: error: unknown: JSON validation failed: default has wrong type, expected String found map[string]interface {}
❯ ftl config set --db --json echo.default '"{\"name\": \"beepboop\"}"'

Note

Finally! But yuck

❯ ftl config get echo.default
"{\"name\": \"beepboop\"}"
❯ ftl config set --db echo.default '{"name": 3}'
❯ ftl config get echo.default
"{\"name\": 3}"
@github-actions github-actions bot added the triage Issue needs triaging label Nov 15, 2024
@ftl-robot ftl-robot mentioned this issue Nov 15, 2024
@alecthomas
Copy link
Collaborator

The error is correct, but could perhaps be clearer... --json is for specifying strongly typed values, the FTL type is String and you're trying to put a map into it.

@matt2e
Copy link
Collaborator

matt2e commented Nov 18, 2024

--json has tripped a number of people up I think at this point. I wonder if we assume the input is a json string, and then have a fallback of if the expected type is string and it could not be parsed by json then we just use the input string as is...

@bradleydwyer bradleydwyer added P3 next Work that will be be picked up next and removed triage Issue needs triaging labels Nov 25, 2024
worstell pushed a commit that referenced this issue Dec 16, 2024
Fixes #3408

Adds more info to the `--json` flag for `ftl config/secret set` commands

```
Command flags:
  --json    Assume input value is JSON. Note: For string secrets, the JSON value
            itself must be a string (e.g., '"hello"' or '"{'key': 'value'}"').
```

and

```
Command flags:
  --json    Assume input value is JSON. Note: For string configs, the JSON value
            itself must be a string (e.g., '"hello"' or '"{'key': 'value'}"').
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
next Work that will be be picked up next P3
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants