Skip to content

Conversation

mikeland73
Copy link
Contributor

Summary

This fixes a NPE in autodetect. Previously when initializing a config with a directory that already contained a config we would return (nil, nil) but this is a mistake and a bit inconsistent with typical go. This changes it so that if config already exists we return an error instead.

IMO this also provides better UX displaying a message indicating config already exists.

This does have a minor backward compatibility issue. If users where used to calling devbox init and having it not fail they would now need to first test if devbox.json already exists.

How was it tested?

@mikeland73 mikeland73 requested review from gcurtis and savil October 10, 2024 21:36
@Lagoja
Copy link
Contributor

Lagoja commented Oct 10, 2024

If we want to be really cautious/backwards compatible here, we could have it emit a warning for 1 release, and then make it a hard error in a subsequent release

Copy link
Collaborator

@savil savil left a comment

Choose a reason for hiding this comment

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

Please lets switch this to a no-op error if we can?

if path == "" || path == "." {
path, _ = os.Getwd()
}
return usererr.New("devbox.json already exists in %q.", path)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could we make switch this to a warning emitted instead and make it a non-error?
I don't think its that bad to run devbox init if a devbox.json already exists. Its useful for scripts.

@mikeland73 mikeland73 merged commit bb67992 into main Oct 11, 2024
29 checks passed
@mikeland73 mikeland73 deleted the landau/autodetect-fix branch October 11, 2024 23:11
Copy link

sentry-io bot commented Oct 24, 2024

Suspect Issues

This pull request was deployed and Sentry observed the following issues:

  • ‼️ **Generic Error: <redacted *errors.withStack>: <redacted errors.withStack>: <redacted usererr.combined> go.jetpack.io/devbox/internal/boxcli/usererr in... View Issue

Did you find this useful? React with a 👍 or 👎

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.

4 participants