Skip to content

Commit 8380c14

Browse files
committed
Revert "nix: improve redacted nix error (#1776)"
This reverts commit 12f2daf.
1 parent 6d9ea74 commit 8380c14

File tree

1 file changed

+5
-14
lines changed

1 file changed

+5
-14
lines changed

internal/nix/nix.go

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import (
1818
"github.com/pkg/errors"
1919
"go.jetpack.io/devbox/internal/boxcli/featureflag"
2020
"go.jetpack.io/devbox/internal/boxcli/usererr"
21-
"go.jetpack.io/devbox/internal/redact"
2221

2322
"go.jetpack.io/devbox/internal/debug"
2423
)
@@ -77,22 +76,15 @@ func (*Nix) PrintDevEnv(ctx context.Context, args *PrintDevEnvArgs) (*PrintDevEn
7776
if insecure, insecureErr := IsExitErrorInsecurePackage(err, "" /*installable*/); insecure {
7877
return nil, insecureErr
7978
} else if err != nil {
80-
safeArgs := make([]string, 0, len(cmd.Args))
81-
for _, a := range cmd.Args {
82-
if a == args.FlakeDir {
83-
a = "<redacted path>"
84-
}
85-
safeArgs = append(safeArgs, a)
86-
}
87-
return nil, redact.Errorf("nix command: %s", redact.Safe(safeArgs))
79+
return nil, errors.Wrapf(err, "Command: %s", cmd)
8880
}
8981

9082
if err := json.Unmarshal(data, &out); err != nil {
91-
return nil, redact.Errorf("unmarshal nix print-dev-env output: %w", redact.Safe(err))
83+
return nil, errors.WithStack(err)
9284
}
9385

9486
if err = savePrintDevEnvCache(args.PrintDevEnvCachePath, out); err != nil {
95-
return nil, redact.Errorf("savePrintDevEnvCache: %w", redact.Safe(err))
87+
return nil, errors.WithStack(err)
9688
}
9789
}
9890

@@ -183,13 +175,12 @@ func Version() (string, error) {
183175
cmd := command("--version")
184176
outBytes, err := cmd.Output()
185177
if err != nil {
186-
return "", redact.Errorf("nix command: %s", redact.Safe(cmd))
178+
return "", errors.WithStack(err)
187179
}
188180
out := string(outBytes)
189181
const prefix = "nix (Nix) "
190182
if !strings.HasPrefix(out, prefix) {
191-
return "", redact.Errorf(`nix command %s: expected %q prefix, but output was: %s`,
192-
redact.Safe(cmd), redact.Safe(prefix), redact.Safe(out))
183+
return "", errors.Errorf(`Expected "%s" prefix, but output from nix --version was: %s`, prefix, out)
193184
}
194185
version = strings.TrimSpace(strings.TrimPrefix(out, prefix))
195186
return version, nil

0 commit comments

Comments
 (0)