tektoncd/pipeline

Replace `nil, nil` returns with sentinel errors in status helpers

Offen

#9.494 geöffnet am 04.03.2026

 (8 Kommentare) (0 Reaktionen) (1 zugewiesene Person)Go (1.943 Forks)auto 404
good first issuehelp wantedkind/cleanup

Repository-Metriken

Stars
 (9.013 Sterne)
PR-Merge-Metriken
 (PR-Metriken ausstehend)

Beschreibung

Summary

Several functions in the status packages return nil, nil (no result and no error) to indicate "not found" or "not applicable" conditions. Each has a //nolint:nilnil comment noting that a sentinel error would be more ergonomic. This makes callers harder to reason about since they must check both return values for nil.

Locations

pkg/pod/status.go:

  • Line 569: return nil, nil //nolint:nilnil // would be more ergonomic to return a sentinel error
  • Line 584: return nil, nil //nolint:nilnil // would be more ergonomic to return a sentinel error

pkg/status/status.go:

  • Line 42: return nil, nil //nolint:nilnil // would be more ergonomic to return a sentinel error
  • Line 60: return nil, nil //nolint:nilnil // would be more ergonomic to return a sentinel error

What to do

  1. Define sentinel errors in the appropriate package, e.g.:
    var ErrNotFound = errors.New("resource not found")
    
  2. Replace return nil, nil with return nil, ErrNotFound (or a more descriptive sentinel)
  3. Update callers to use errors.Is(err, ErrNotFound) instead of checking for nil result
  4. Remove the //nolint:nilnil comments

How to find callers

# Find functions that return nil, nil
rg "return nil, nil" pkg/pod/status.go pkg/status/status.go

# Find callers of those functions to update
# (use your IDE or grep for the function names)

How to verify

  • go build ./... passes
  • go test ./pkg/pod/... ./pkg/status/... passes
  • go vet ./... passes
  • The nilnil linter no longer needs to be suppressed for these locations

/kind cleanup

Contributor Guide