-
-
Notifications
You must be signed in to change notification settings - Fork 146
Closed
Labels
bug🐛 An issue with the system🐛 An issue with the system
Description
Problem
The current codebase uses ErrWrappingFormat (defined as "%w: %w") in fmt.Errorf calls, which violates Go's rule that only one %w verb is allowed per format string. This creates invalid error wrapping patterns that can fail go vet and behave unexpectedly.
Root Cause
In errors/errors.go:
ErrWrappingFormat = "%w: %w" // ❌ Invalid - multiple %w verbs
ErrStringWrappingFormat = "%w: %s" // ✅ Valid - single %w verbAffected Files (16 occurrences across 8 files)
pkg/auth/cloud/aws/setup.go: 2 usagespkg/auth/identities/aws/user.go: 2 usagespkg/auth/types/github_oidc_credentials.go: 2 usagespkg/auth/manager.go: 2 usagespkg/config/load.go: 2 usagesinternal/exec/terraform_generate_planfile.go: 3 usagesinternal/exec/packer_output.go: 1 usagecmd/auth_user.go: 2 usages
Solution
Replace all instances of ErrWrappingFormat with ErrStringWrappingFormat:
- fmt.Errorf(errUtils.ErrWrappingFormat, errUtils.ErrSomeError, err)
+ fmt.Errorf(errUtils.ErrStringWrappingFormat, errUtils.ErrSomeError, err)This ensures:
- Go vet compliance
- Proper error wrapping with single %w verb
- Consistent error handling patterns
Discovery Context
Discovered during code review in PR #1475: #1475 (comment)
Acceptance Criteria
- Replace all 16 occurrences of
ErrWrappingFormatwithErrStringWrappingFormat - Verify
go vetpasses on all affected files - Test error wrapping behavior remains correct
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bug🐛 An issue with the system🐛 An issue with the system