fix: Don't crash on invalid config import
Currently if you pass a bogus JSON file to the `config import` command, you get a nil deref. Detect this and fail with a helpful error message instead.
This commit is contained in:
parent
f89975603e
commit
46ea0b79ff
@ -53,6 +53,10 @@ The path must be for a json or yaml file.`,
|
||||
return err
|
||||
}
|
||||
|
||||
if file.Settings == nil || file.Server == nil {
|
||||
return errors.New("invalid configuration file: 'settings' or 'server' fields are missing. Please ensure you are importing a file generated by the 'config export' command")
|
||||
}
|
||||
|
||||
file.Settings.Key = key
|
||||
err = st.Settings.Save(file.Settings)
|
||||
if err != nil {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user