Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions pkg/config/app_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,15 +191,25 @@ func loadUserConfig(configFiles []*ConfigFile, base *UserConfig) (*UserConfig, e
return nil, err
}

content, err = migrateUserConfig(path, content)
existingCustomCommands := base.CustomCommands
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line needs to be before we make any potential modifications to base , so I have just moved it fully before the parsing.


var node yaml.Node
err = yaml.Unmarshal(content, &node)
if err != nil {
return nil, err
return nil, fmt.Errorf("Failed to parse config at `%s` as YAML document. Please check your file before opening an issue\n %w", path, err)
}

existingCustomCommands := base.CustomCommands

if err := yaml.Unmarshal(content, base); err != nil {
return nil, fmt.Errorf("The config at `%s` couldn't be parsed, please inspect it before opening up an issue.\n%w", path, err)
err = node.Decode(base)
if err != nil {
// We attempt to migrate the configuration, and then re-attempt to unmarshal
content, err = migrateUserConfig(path, content)
if err != nil {
return nil, err
}
err = yaml.Unmarshal(content, base)
if err != nil {
return nil, fmt.Errorf("Failed to decode config at path `%s` after attempting auto-migration. Please check your file before opening an issue\n %w", path, err)
}
}

base.CustomCommands = append(base.CustomCommands, existingCustomCommands...)
Expand Down
Loading