Skip to content
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 three redundant error-related dependencies #34794

Merged
merged 2 commits into from
Mar 8, 2024

Conversation

apparentlymart
Copy link
Contributor

In the early days the Go standard library lacked various useful helpers for wrapping and combining errors and so various parties, including HashiCorp itself, wrote separate libraries to fill those gaps.

However, recent improvements to the standard library have made those all redundant. There's now sufficient functionality in the standard library to support all of Terraform's error wrapping and combining needs.

This therefore removes all of the uses of the following three modules from our non-legacy packages:

  • github.com/pkg/errors
  • github.com/hashicorp/go-multierror
  • github.com/hashicorp/errwrap

The latter two still have callers in the packages under our legacy directory, but we'll hopefully eventually take care of those with a combination of #34793 and #34772.

The first has no remaining callers in this repository, but unfortunately it's still used by the Consul SDK that we depend on for the consul remote state backend. Hopefully a future version of that will switch to using the standard library functions instead too, if that hasn't already happened.

This is motivated just by minimizing the number of external dependencies Terraform has. We prefer to use standard library functionality instead of third-party libraries whenever possible.


As a bonus, this also fills two prior gaps in the unit testing in package tfdiags.

This functionality is now provided by the "errors" package in the standard
library, so the HashiCorp-specific library is obsolete.

This also removed our one direct use of github.com/pkg/errors, which we
were using in a way that was totally redundant with the stdlib package
errors. However, it lives on as an indirect dependency through the Consul
backend's dependency on the Consul SDK, which uses that library.
HashiCorp needed support for wrapping multiple errors into a single error
and for wrapping one error inside another long before that was in the
standard library, and so built its own libraries for those needs.

However, the standard library now has its own answers for both and so the
HashiCorp libraries are redundant. We've already eliminated all use of
both elsewhere in Terraform (except for some legacy packages that predate
tfdiags anyway), so we no longer need to support them in package tfdiags.
@apparentlymart apparentlymart added the dependencies Auto-pinning label Mar 8, 2024
@apparentlymart apparentlymart requested a review from a team March 8, 2024 02:53
@apparentlymart apparentlymart self-assigned this Mar 8, 2024
@apparentlymart apparentlymart requested review from a team as code owners March 8, 2024 02:53
Copy link
Member

@hanshasselberg hanshasselberg left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@SarahFrench SarahFrench left a comment

Choose a reason for hiding this comment

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

LGTM from the perspective of the gcs backend. Thanks for cleaning this up!

Copy link
Member

@jar-b jar-b left a comment

Choose a reason for hiding this comment

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

S3 backend changes LGTM 👍

@apparentlymart apparentlymart merged commit e6ad0c2 into main Mar 8, 2024
10 checks passed
@apparentlymart apparentlymart deleted the f-stdlib-errwrap branch March 8, 2024 15:54
Copy link

github-actions bot commented Mar 8, 2024

Reminder for the merging maintainer: if this is a user-visible change, please update the changelog on the appropriate release branch.

Copy link

github-actions bot commented Apr 8, 2024

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 8, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
dependencies Auto-pinning
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants