Skip to content

Revert "nix: improve redacted nix error (#1776)" #1778

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

savil
Copy link
Collaborator

@savil savil commented Feb 3, 2024

Summary

Reason for reverting: to omit this PR from the Devbox release.

When I run devbox run -- DEVBOX_DEBUG=1 go test -v -run TestScripts/global ./testscripts/... on my Mac with nix 2.20, I get this error.
The output below is from main that includes this redacted-error improvement PR #1776

      2024/02/02 17:15:34 Running print-dev-env cmd: /nix/var/nix/profiles/default/bin/nix print-dev-env /var/folders/zv/r3sx92_94gq86_rq3yn1ky2h0000gn/T/TestScripts4205203385/001/.local/share/devbox/global/default/.devbox/gen/flake --extra-experimental-features ca-derivations --option experimental-features nix-command flakes fetch-closure --json
        Error: nix command: [nix print-dev-env <redacted path> --extra-experimental-features ca-derivations --option experimental-features nix-command flakes fetch-closure --json]

        2024/02/02 17:15:34
        ExecutionID:75d13152cb3f4b089677cfe7ef08a2c4
        nix command: [nix print-dev-env <redacted path> --extra-experimental-features ca-derivations --option experimental-features nix-command flakes fetch-closure --json]
        go.jetpack.io/devbox/internal/nix.(*Nix).PrintDevEnv
        	/Users/savil/code/jetpack/devbox/internal/nix/nix.go:87
        go.jetpack.io/devbox/internal/devbox.(*Devbox).computeEnv
        	/Users/savil/code/jetpack/devbox/internal/devbox/devbox.go:831

but prior to this redact PR, the error message was the following which makes diagnosis of the error possible:

        Error: Command: /nix/var/nix/profiles/default/bin/nix print-dev-env /var/folders/zv/r3sx92_94gq86_rq3yn1ky2h0000gn/T/TestScripts1786708027/001/.local/share/devbox/global/default/.devbox/gen/flake --extra-experimental-features ca-derivations --option experimental-features nix-command flakes fetch-closure --json: exit status 1

        2024/02/02 17:18:51 Command stderr: error (ignored): error: end of string reached
        error:
               … while fetching the input 'path:/var/folders/zv/r3sx92_94gq86_rq3yn1ky2h0000gn/T/TestScripts1786708027/001/.local/share/devbox/global/default/.devbox/gen/flake'

               error: path '«unknown»/var' is a symlink

        2024/02/02 17:18:51
        ExecutionID:4cf67968924744ea918169a68b1cb44f
        exit status 1
        Command: /nix/var/nix/profiles/default/bin/nix print-dev-env /var/folders/zv/r3sx92_94gq86_rq3yn1ky2h0000gn/T/TestScripts1786708027/001/.local/share/devbox/global/default/.devbox/gen/flake --extra-experimental-features ca-derivations --option experimental-features nix-command flakes fetch-closure --json
        go.jetpack.io/devbox/internal/nix.(*Nix).PrintDevEnv
        	/Users/savil/code/jetpack/devbox/internal/nix/nix.go:79
        go.jetpack.io/devbox/internal/devbox.(*Devbox).computeEnv
        	/Users/savil/code/jetpack/devbox/internal/devbox/devbox.go:831

How was it tested?

Copy link
Collaborator Author

savil commented Feb 3, 2024

Current dependencies on/for this PR:

This stack of pull requests is managed by Graphite.

@savil savil requested review from mikeland73 and gcurtis and removed request for mikeland73 February 3, 2024 01:36
}
safeArgs = append(safeArgs, a)
}
return nil, redact.Errorf("nix command: %s", redact.Safe(safeArgs))
Copy link
Collaborator

Choose a reason for hiding this comment

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

I fumbled this with the original PR. I was going to try and sanitize the individual args, but then decided not to and ended up with a weird in between implementation. The line was supposed to just be:

redact.Errorf("nix command: %s", redact.Safe(cmd))

and not have the safeArgs stuff.

Redacted error messages are not normally redacted and retain their normal message unless they're sent to Sentry. But here I modified the actual slice of args, so it ended up always redacted.

If this isn't blocking anything, I can just submit a fix PR later.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think I see. I need to learn about our redact logic more.

Assuming it's okay, I'm going to land this, just so that the Devbox release is unblocked. Since it's a small PR, perhaps you could re-submit with the better fix and if it works out timing-wise then it could be included in the release as well!

@gcurtis
Copy link
Collaborator

gcurtis commented Feb 5, 2024

@savil fixed in #1782.

@savil savil force-pushed the savil/revert-redact-error-change branch from 8380c14 to c8f8e5c Compare February 5, 2024 16:47
@savil savil closed this Feb 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants