Problem
Nine call sites in pkg/workflow use fmt.Errorf("%s", someString) where no error is being wrapped. This is an anti-pattern: fmt.Errorf with %s (not %w) allocates a format string unnecessarily, and the intent — constructing a new error from a string — is better expressed with errors.New(...).
The perfsprint linter (enabled in .golangci.yml) targets exactly this pattern, and errorlint would flag it too if it weren't currently disabled due to golangci-lint v2 bugs.
Locations
| File |
Line |
Current |
pkg/workflow/workflow_errors.go |
261 |
fmt.Errorf("%s", sb.String()) |
pkg/workflow/engine_validation.go |
142 |
fmt.Errorf("%s", errMsg) |
pkg/workflow/template_injection_utils.go |
165 |
fmt.Errorf("%s", builder.String()) |
pkg/workflow/permissions_validation.go |
346 |
fmt.Errorf("%s", errorMsg.String()) |
pkg/workflow/dangerous_permissions_validation.go |
96 |
fmt.Errorf("%s", strings.Join(...)) |
pkg/workflow/safe_update_enforcement.go |
257 |
fmt.Errorf("%s", sb.String()) |
pkg/workflow/tools_validation_github_toolsets.go |
97 |
fmt.Errorf("%s", errMsg.String()) |
pkg/workflow/runtime_validation.go |
91 |
fmt.Errorf("%s", errorMsg) |
pkg/workflow/engine_definition.go |
280 |
fmt.Errorf("%s", errMsg) |
Recommendation
Replace each with errors.New(...):
// Before
return fmt.Errorf("%s", sb.String())
// After
return errors.New(sb.String())
No behaviour change. Import "errors" where not already present and remove the "fmt" import if it becomes unused.
Severity
- Medium — code smell, minor allocation waste, violates linter intent
Validation
Generated by Sergo - Serena Go Expert · ● 388.4K · ◷
Problem
Nine call sites in
pkg/workflowusefmt.Errorf("%s", someString)where no error is being wrapped. This is an anti-pattern:fmt.Errorfwith%s(not%w) allocates a format string unnecessarily, and the intent — constructing a new error from a string — is better expressed witherrors.New(...).The
perfsprintlinter (enabled in.golangci.yml) targets exactly this pattern, anderrorlintwould flag it too if it weren't currently disabled due to golangci-lint v2 bugs.Locations
pkg/workflow/workflow_errors.gofmt.Errorf("%s", sb.String())pkg/workflow/engine_validation.gofmt.Errorf("%s", errMsg)pkg/workflow/template_injection_utils.gofmt.Errorf("%s", builder.String())pkg/workflow/permissions_validation.gofmt.Errorf("%s", errorMsg.String())pkg/workflow/dangerous_permissions_validation.gofmt.Errorf("%s", strings.Join(...))pkg/workflow/safe_update_enforcement.gofmt.Errorf("%s", sb.String())pkg/workflow/tools_validation_github_toolsets.gofmt.Errorf("%s", errMsg.String())pkg/workflow/runtime_validation.gofmt.Errorf("%s", errorMsg)pkg/workflow/engine_definition.gofmt.Errorf("%s", errMsg)Recommendation
Replace each with
errors.New(...):No behaviour change. Import
"errors"where not already present and remove the"fmt"import if it becomes unused.Severity
Validation
go build ./pkg/workflow/passesgolangci-lint run ./pkg/workflow/shows no new warningsgo test ./pkg/workflow/...passes