Skip to content

pkg/workflow + pkg/parser: ~580 fmt.Errorf calls missing %w break errors.Is/As chains #29184

@github-actions

Description

@github-actions

Problem

580 occurrences of fmt.Errorf(...) without the %w verb were found in non-test production code across 173 files, versus 1004 occurrences that correctly use %w. This means roughly 37% of error wrapping discards the original error and breaks errors.Is / errors.As lookup chains.

High-concentration files include:

  • pkg/parser/schedule_fuzzy_scatter.go — 31 instances without %w
  • pkg/workflow/stop_after.go — 16 instances without %w
  • pkg/workflow/compiler_pre_activation_job.go — 10 instances without %w
  • pkg/workflow/call_workflow_validation.go — 9 instances without %w
  • pkg/workflow/engine_validation.go — 17 instances without %w

Example from pkg/workflow/call_workflow_validation.go:

// Without %w — caller cannot use errors.Is(err, someTargetErr)
return fmt.Errorf("call workflow: unsupported trigger %q", trigger)

Impact

  • Severity: High
  • Affected Files: 173 production files
  • Risk: Loss of error context and inability to type-assert or sentinel-check errors upstream; harder to diagnose production failures

Recommendation

For errors that wrap an underlying err, add %w:

Before:

return fmt.Errorf("failed to parse schedule: %s", err)

After:

return fmt.Errorf("failed to parse schedule: %w", err)

For errors with no underlying cause to wrap, fmt.Errorf without %w is intentional and correct — only wrap when an err variable is being included.

A focused sweep of the high-count files listed above would address the majority of cases.

Validation

  • Run go vet ./... — it warns on fmt.Errorf with %s when an error is present
  • Add a golangci-lint rule wrapcheck or errorlint to catch future occurrences
  • Run grep -n 'fmt.Errorf.*%s.*err' pkg/ to surface remaining candidates
  • Verify errors.Is/As tests still pass after migration

Estimated Effort: Medium (mechanical but requires careful review to avoid wrapping non-error strings)

Generated by Sergo - Serena Go Expert · ● 536.8K ·

  • expires on May 6, 2026, 8:44 PM UTC

Metadata

Metadata

Labels

cookieIssue Monster Loves Cookies!sergo

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions