Skip to content

[lint-monster] [LintMonster] Fix Panic in Library Code (28 findings) #34359

@github-actions

Description

@github-actions

Overview

Daily lint scan identified 28 panic() calls in library code that should return errors instead. Library code should not panic—it should allow callers to handle errors gracefully.

Scope

  • Primary: pkg/workflow/* — majority of findings
  • Secondary: pkg/testutil/* — test utility panic calls
  • Rationale: These are library functions callable by external consumers; panic prevents clean error handling

Representative Violations

pkg/workflow/permissions_toolset_data.go:44 — avoid panic
pkg/workflow/pi_engine.go:139 — avoid panic
pkg/workflow/strings.go:176 — avoid panic
pkg/testutil/tempdir.go:33, 42 — avoid panic

Full list in lint-diagnostics.txt (search for "avoid panic")

Remediation Strategy

Skill Guidance: Use .github/skills/error-recovery-patterns/SKILL.md for error handling patterns

For each panic:

  1. Identify the context where panic occurs (validation, configuration, initialization)
  2. Define a returning function with error return type
  3. Replace panic(msg) with return fmt.Errorf("msg")
  4. Propagate error to caller; caller decides whether to panic or handle gracefully
  5. Update tests to check error conditions instead of expecting panic

Example:

// BEFORE
func parseConfig(raw string) Config {
    if invalid {
        panic("config validation failed")  // ❌ Library panics
    }
    return config
}

// AFTER
func parseConfig(raw string) (Config, error) {
    if invalid {
        return Config{}, fmt.Errorf("config validation failed")  // ✅ Returns error
    }
    return config, nil
}

Validation Checklist

  • Convert panic calls to error returns in all library functions
  • Update call sites to check returned errors (or propagate)
  • Convert panic-based tests to error-checking tests
  • Run make golint-custom — verify zero "avoid panic" violations
  • Run go test -v ./pkg/workflow/ ./pkg/testutil/ — all pass
  • Run make build — binary compiles

Expected Outcome

28 panic-in-library violations resolved. All callers properly handle errors.

Generated by 🧌 LintMonster · ● hai45 109K ·

  • expires on May 31, 2026, 3:50 AM UTC

Metadata

Metadata

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