Skip to content

Commit a58e22d

Browse files
committed
fix(config): report only the cause when an api_key reference cannot be resolved
1 parent a15955e commit a58e22d

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

‎internal/config/api_key_env.go‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package config
22

33
import (
44
"context"
5+
"errors"
56
"fmt"
67
"os"
78
"strings"
@@ -102,7 +103,12 @@ func resolveAPIKeyRef(c *Config) error {
102103
}
103104
resolved, err := secret.NewResolver().ExpandSecretRefs(context.Background(), c.APIKey)
104105
if err != nil {
105-
return fmt.Errorf("api_key: %w", err)
106+
// ExpandSecretRefs prefixes its error with the reference text; the
107+
// operator already knows which field this is, so report the cause only.
108+
if cause := errors.Unwrap(err); cause != nil {
109+
err = cause
110+
}
111+
return fmt.Errorf("api_key: could not resolve the reference: %w", err)
106112
}
107113
if resolved == "" {
108114
return fmt.Errorf("api_key: the reference resolved to an empty value")

0 commit comments

Comments
 (0)