fix: Don't crash on invalid config import (#5640)

This commit is contained in:
Brendan Jackman 2025-12-28 21:04:23 +00:00 committed by GitHub
parent 20bfd131c6
commit 79d1aa9229
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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 {