Skip to content

Commit

Permalink
fix: fix the misleading log when applying invalid config (runfinch#119)
Browse files Browse the repository at this point in the history
Issue #, if available:
runfinch#118

*Description of changes:*
fix the misleading log when applying invalid config

*Testing done:*
make test-unit
make lint


- [ X ] I've reviewed the guidance in CONTRIBUTING.md


#### License Acceptance

By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 license.

Signed-off-by: Ziwen Ning <[email protected]>
  • Loading branch information
ningziwen authored Dec 14, 2022
1 parent 9b275bc commit b4f74c5
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cmd/finch/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func TestXmain(t *testing.T) {
{
name: "failed to load finch config because of invalid YAML",
wantErr: fmt.Errorf("failed to load config: %w",
fmt.Errorf("failed to unmarshal config file, using default values: %w",
fmt.Errorf("failed to unmarshal config file: %w",
&yaml.TypeError{Errors: []string{"line 1: cannot unmarshal !!str `this is...` into config.Finch"}},
),
),
Expand Down
2 changes: 1 addition & 1 deletion pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func Load(fs afero.Fs, cfgPath string, log flog.Logger, systemDeps LoadSystemDep

var cfg Finch
if err := yaml.Unmarshal(b, &cfg); err != nil {
return nil, fmt.Errorf("failed to unmarshal config file, using default values: %w", err)
return nil, fmt.Errorf("failed to unmarshal config file: %w", err)
}

defCfg := applyDefaults(&cfg, systemDeps, mem)
Expand Down
2 changes: 1 addition & 1 deletion pkg/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ cpus: 8
},
want: nil,
wantErr: fmt.Errorf(
"failed to unmarshal config file, using default values: %w",
"failed to unmarshal config file: %w",
&yaml.TypeError{Errors: []string{"line 1: cannot unmarshal !!str `this is...` into config.Finch"}},
),
},
Expand Down

0 comments on commit b4f74c5

Please sign in to comment.