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

CLI - Exit when config is malformed #1669

Open
wants to merge 1 commit into
base: bfops/remove-project-config
Choose a base branch
from

Conversation

bfops
Copy link
Collaborator

@bfops bfops commented Sep 4, 2024

Description of Changes

Fixes #1668.
Fixes #1581.

API and ABI breaking changes

This will no longer overwrite malformed config files, but does not otherwise change our API.

Expected complexity level and risk

2

Testing

It would be reasonable to ask me to turn these into smoketests..

$ rm -f ~/.spacetime/config.toml

$ cargo run -- call foo bar
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.21s
     Running `target/debug/spacetime call foo bar`
Error: The dns resolution of `foo` failed.

$ cat ~/.spacetime/config.toml
default_server = "testnet"

[[server_configs]]
nickname = "local"
host = "127.0.0.1:3000"
protocol = "http"

[[server_configs]]
nickname = "testnet"
host = "testnet.spacetimedb.com"
protocol = "https"

$ sed -i 's/=/>/' ~/.spacetime/config.toml

$ cargo run -- call foo bar
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.19s
     Running `target/debug/spacetime call foo bar`
config file "/home/lead/.spacetime/config.toml" is invalid: Error {
    inner: Error {
        inner: TomlError {
            message: "expected `.`, `=`",
            original: Some(
                "default_server > \"testnet\"\n\n[[server_configs]]\nnickname > \"local\"\nhost > \"127.0.0.1:3000\"\nprotocol > \"http\"\n\n[[server_configs]]\nnickname > \"testnet\"\nhost > \"testnet.spacetimedb.com\"\nprotocol > \"https\"\n",
            ),
            keys: [],
            span: Some(
                15..16,
            ),
        },
    },
}
Error: TOML parse error at line 1, column 16
  |
1 | default_server > "testnet"
  |                ^
expected `.`, `=`

$ cat ~/.spacetime/config.toml
default_server > "testnet"

[[server_configs]]
nickname > "local"
host > "127.0.0.1:3000"
protocol > "http"

[[server_configs]]
nickname > "testnet"
host > "testnet.spacetimedb.com"
protocol > "https"

@bfops bfops changed the base branch from master to bfops/remove-project-config September 4, 2024 18:31
@bfops bfops marked this pull request as ready for review September 4, 2024 18:32
@bfops bfops added release-any To be landed in any release window CLI only This change only affects the CLI behavior labels Sep 4, 2024
@bfops bfops requested review from gefjon and removed request for gefjon September 5, 2024 17:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLI only This change only affects the CLI behavior release-any To be landed in any release window
Projects
None yet
1 participant