Skip to content

[plan] Add Unwrap() methods to custom error types #16610

@github-actions

Description

@github-actions

Objective

Add Cause error field and Unwrap() error method to 4 custom error types that currently can't participate in Go's error chain inspection.

Context

From Sergo analysis discussion #16458 (hybrid-symbol-error-analysis). Currently, only OperationError correctly implements Unwrap(). The other 4 custom error types break idiomatic Go error handling with errors.Is() and errors.As().

Types to Fix

  1. WorkflowValidationErrorpkg/workflow/error_helpers.go:14
  2. ConfigurationErrorpkg/workflow/error_helpers.go:116
  3. GitHubToolsetValidationErrorpkg/workflow/github_toolset_validation_error.go:16
  4. SharedWorkflowErrorpkg/workflow/shared_workflow_error.go:16

Reference: Correct Implementation

// OperationError (GOOD - has Unwrap)
type OperationError struct {
    Operation  string
    EntityType string
    EntityID   string
    Cause      error  // ✅ Has Cause field
    Suggestion string
    Timestamp  time.Time
}

func (e *OperationError) Unwrap() error {
    return e.Cause  // ✅ Implements Unwrap
}

Approach

  1. Add optional Cause error field to each of the 4 structs
  2. Implement Unwrap() error on each struct returning the Cause field
  3. Update constructor functions to accept an optional cause parameter (use variadic or a separate WithCause pattern to maintain backward compatibility)
  4. Add test cases using errors.Is() and errors.As() to verify error chain inspection works

Files to Modify

  • pkg/workflow/error_helpers.goWorkflowValidationError, ConfigurationError
  • pkg/workflow/github_toolset_validation_error.goGitHubToolsetValidationError
  • pkg/workflow/shared_workflow_error.goSharedWorkflowError

Acceptance Criteria

  • All 4 error types have a Cause error field
  • All 4 error types implement Unwrap() error
  • Constructor functions maintain backward compatibility (existing call sites not broken)
  • Tests verify errors.Is() and errors.As() work through error chains
  • make agent-finish passes (build, test, lint, fmt)

Generated by Plan Command for issue #discussion #16458

  • expires on Feb 20, 2026, 5:34 PM UTC

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions