-
Notifications
You must be signed in to change notification settings - Fork 116
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
Remove exit error types #352
Conversation
40f9679
to
512b45a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me 🚀
_, err := tf.Show(context.Background()) | ||
if !errors.As(err, &noInit) { | ||
t.Fatalf("expected error ErrNoInit, got %T: %s", err, err) | ||
if err == nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Not sure if its worth checking for the (new) expected error in these cases or not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The proposed change in principle LGTM, but there's now a number of tests which are failing, so I think we either need to reconsider the scope, or change the tests.
512b45a
to
0934b50
Compare
Rebased, but this change unintentionally broke the |
a00c1a5
to
a49cfbf
Compare
a49cfbf
to
6faca8b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't do any "deeper" checks in terms of reading through the relevant LS code, but I can confirm that all LS tests are still passing with these changes, i.e. we aren't relying on any of the error types being removed in LS.
Let's ship it!
Time will tell how much we're affected by Hyrum's Law 😁
This change unfortunately makes all our test cases that expect an error fail within https://github.com/auth0/terraform-provider-auth0 e.g.
To reproduce:
|
Thanks @sergiught, we're looking into this now. Stderr did not make it into the error wrapping, it seems. |
Closes #296.
This PR proposes a breaking change to the terraform-exec API removing the following error types:
ErrConfigInvalid
ErrLockIdInvalid
ErrMissingVar
ErrNoConfig
ErrNoInit
ErrNoWorkspace
ErrStateLocked
ErrStatePlanRead
ErrTFVersionMismatch
ErrWorkspaceExists
The above error types are returned based on parsing the human-readable output of Terraform CLI via regex. The human-readable output of Terraform CLI is not designed for machine parsing, and can change at any time, as it is not covered by the Terraform v1.x Compatibility Promises. These changes, along with trivial text formatting issues, are a common cause of test failures in terraform-exec.
I don't think maintaining these is worth the work, in the absence of a clear use case for these errors. If you have one, please comment here or on the linked issue.
Note that the following errors are not removed:
ErrVersionMismatch
ErrNoSuitableBinary
ErrManualEnvVar
In particular, the compatibility error
ErrVersionMismatch
, which is based on terraform-exec's knowledge of which flags and commands can be used with which version of Terraform, is not removed.As Terraform's machine-readable UI (
-json
streaming format) matures, I expect Terraform itself is the best place to build more structure into errors and diagnostics if necessary. For example, diagnostics could contain an error symbol in addition to their human-readable summary and description.