Skip to content

Commit fb41d1d

Browse files
committed
fix: ensure that all configs are validated
1 parent 35a32a9 commit fb41d1d

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

internal/cli/run.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,11 @@ func run(cmd *cobra.Command, rc *RunArgs) error {
281281
return err
282282
}
283283

284+
err = cfg.Validate()
285+
if err != nil {
286+
return fmt.Errorf("invalid config: %w", err)
287+
}
288+
284289
err = cfg.UI.KeyBinds.Validate()
285290
if err != nil {
286291
return fmt.Errorf("validate key binds: %w", err)
@@ -481,7 +486,7 @@ func loadAnyRuntimeConfigs(grcPath, prcPath string, tm policy.TrustMode) (*confi
481486
thm := cl.GetTheme()
482487
sp := setup.NewPrompter(thm)
483488

484-
trc, rcPath, rcErr := trustMgr.LoadTrustedRuntimeConfig(prcPath, sp, tm)
489+
trc, _, rcErr := trustMgr.LoadTrustedRuntimeConfig(prcPath, sp, tm)
485490
if rcErr != nil {
486491
return nil, nil, fmt.Errorf("load runtime config: %w", rcErr)
487492
}
@@ -494,12 +499,6 @@ func loadAnyRuntimeConfigs(grcPath, prcPath string, tm policy.TrustMode) (*confi
494499
// Merge the trusted project runtime config into the global runtime config.
495500
cfg.Command.Merge(trc.Command)
496501

497-
// Re-validate the merged config.
498-
err = cfg.Validate()
499-
if err != nil {
500-
return nil, thm, fmt.Errorf("invalid merged config %q, %q: %w", grcPath, rcPath, err)
501-
}
502-
503502
return cfg, thm, nil
504503
}
505504

0 commit comments

Comments
 (0)