Skip to content

Unify error structure across WorkflowInstance and TaskExecution#9

Merged
ricardozanini merged 24 commits intomainfrom
feature/unify-error-structure
Apr 29, 2026
Merged

Unify error structure across WorkflowInstance and TaskExecution#9
ricardozanini merged 24 commits intomainfrom
feature/unify-error-structure

Conversation

@ricardozanini
Copy link
Copy Markdown

Summary

Unifies error handling across WorkflowInstance and TaskExecution to align with Serverless Workflow 1.0.0 Error specification (RFC 9457 Problem Details).

Previously, TaskExecution had a simple errorMessage string field while WorkflowInstance had a complex Error object. This PR makes both use the same structured Error type with five fields: type, title, detail, status, and instance.

Changes

Database Layer

  • Added 5 error columns to task_instances table: error_type, error_title, error_detail, error_status, error_instance
  • Updated PostgreSQL trigger normalize_task_event() to extract error fields from JSONB events

Domain Model

  • Renamed WorkflowInstanceErrorError (reusable by both types)
  • Added Error field to TaskExecution (replaced errorMessage string)

Storage Layer (JPA)

  • Renamed WorkflowInstanceErrorEntityErrorEntity (embeddable)
  • Added ErrorEntity field to TaskInstanceEntity
  • Renamed WorkflowInstanceErrorEntityMapperErrorEntityMapper
  • Updated both entity mappers to use ErrorEntityMapper

GraphQL API

  • Created IntFilter for integer field filtering
  • Created ErrorFilter for nested error structure filtering
  • Updated TaskExecutionFilter: replaced errorMessage with error field
  • Added error field to WorkflowInstanceFilter
  • Updated FilterConverter to handle error filtering with all operators

Testing

  • Added 3 new integration tests:
    • testWorkflowInstanceWithErrorStructure() - verifies error object structure
    • testTaskExecutionWithErrorStructure() - verifies task error structure
    • testErrorFiltering() - verifies filtering by error fields
  • All 23 integration tests passing
  • Full e2e verification in KIND cluster completed

Documentation

  • Updated CLAUDE.md with unified error handling guidance
  • Added e2e verification documentation
  • Added quick start guides for KIND deployment

Breaking Changes

⚠️ GraphQL Schema Change

The TaskExecution type has changed:

  • Removed: errorMessage: String
  • Added: error: Error (with fields: type, title, detail, status, instance)

Existing clients querying errorMessage will need to update their queries to use the new nested error structure.

Before:

query {
  getTaskExecutions {
    id
    errorMessage
  }
}

After:

query {
  getTaskExecutions {
    id
    error {
      type
      title
      detail
      status
      instance
    }
  }
}

Verification

✅ Clean build: mvn clean install
✅ All tests pass: 23/23 tests (0 failures)
✅ E2E verification in KIND cluster
✅ GraphQL error queries working
✅ Error filtering working (all operators)
✅ Database triggers extracting error fields

Test Results

  • Integration Tests: 23/23 passing
  • E2E Tests: Full deployment verified in KIND
  • GraphQL Queries: Error structure queries working
  • Error Filtering: Tested with eq, gte, and other operators
  • Database: Triggers correctly normalize error events

Related Issues

Closes #9 (if applicable - update issue number)

Checklist

  • Code follows project conventions (CLAUDE.md)
  • Tests added and passing
  • Documentation updated
  • E2E verification completed
  • No security vulnerabilities introduced
  • Breaking changes documented

Screenshots/Examples

GraphQL Query with Error Structure:

query {
  getWorkflowInstance(id: "test-faulted-wf-001") {
    id
    status
    error {
      type
      title
      detail
      status
      instance
    }
  }
}

Error Filtering:

query {
  getWorkflowInstances(
    filter: {
      error: {
        status: { eq: 500 }
        type: { like: "communication" }
      }
    }
  ) {
    id
    status
    error {
      type
      status
    }
  }
}

🤖 Generated with Claude Code

ricardozanini and others added 24 commits April 28, 2026 15:54
Add comprehensive design specification for unifying error handling
between workflow instances and task executions.

Key changes:
- Rename WorkflowInstanceError → Error (reusable type)
- Add error structure to TaskExecution domain model
- Add 5 error columns to task_instances table
- Update PostgreSQL trigger to extract error fields
- Create ErrorFilter for GraphQL error filtering
- Create IntFilter for integer field filtering
- Update both WorkflowInstanceFilter and TaskExecutionFilter

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Comprehensive implementation plan with 21 tasks covering:
- Database schema updates (error columns + trigger)
- Domain model refactoring (Error type unification)
- JPA entity updates (ErrorEntity embedding)
- GraphQL filter enhancements (IntFilter, ErrorFilter)
- Integration tests (error structure + filtering)
- Documentation updates

Each task broken into 2-5 minute TDD steps with exact commands.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Add 5 error columns (error_type, error_title, error_detail, error_status,
error_instance) to task_instances table and update normalize_task_event()
trigger to extract error fields from JSONB events.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Rename to generic Error type that can be used by both WorkflowInstance
and TaskExecution domain models.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Updates WorkflowInstance to use the renamed Error class instead of
WorkflowInstanceError. This fixes compilation errors from Task 3.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Replaces the simple errorMessage string with the complex Error object
to match WorkflowInstance error structure and align with SW 1.0.0 spec.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Renames JPA entity to be generic and reusable by both
WorkflowInstanceEntity and TaskInstanceEntity.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Updates field type and methods to use the renamed ErrorEntity class.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
…n TaskInstanceEntity

Replaces the five individual error columns with an @Embedded ErrorEntity
to match WorkflowInstanceEntity structure. JPA maps the embedded fields
to the existing error_type, error_title, error_detail, error_status,
error_instance columns.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
…tityMapper

Renames mapper to be generic and reusable by both
WorkflowInstanceEntityMapper and TaskInstanceEntityMapper.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
…ityMapper

Updates @Mapper uses annotation to reference the renamed ErrorEntityMapper.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Adds ErrorEntityMapper to @Mapper uses so TaskExecution.error field can
be mapped from TaskInstanceEntity.error.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Add IntFilter to support integer field filtering in GraphQL queries
with eq, gt, gte, lt, lte, and in operations.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Adds nested ErrorFilter to support filtering on error fields (type,
title, detail, status, instance). Used by both WorkflowInstanceFilter
and TaskExecutionFilter.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
…ilter

Remove simple errorMessage StringFilter and add structured ErrorFilter
to enable nested error field filtering.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Add error field with ErrorFilter to enable error filtering for
workflow instances (was previously missing).

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
…rter

Add addIntFilters() and addErrorFilters() methods to convert nested
error filter fields to database column names. Update both convert()
methods to handle error filtering.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Add faulted workflow instance and failed task instance with error
objects for testing error structure in GraphQL queries.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Verify that both workflow instance and task execution error objects
are correctly exposed in GraphQL API with all error fields.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Verify that ErrorFilter works correctly for both workflow instances
and task executions with nested field filtering.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Document Error type unification, field name mappings, and GraphQL
error filtering capabilities.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Complete verification of error structure unification feature:
- Clean build: BUILD SUCCESS (24.479s)
- Test suite: 23/23 tests passing (57.803s)
- Git status: clean working tree
- Code changes: 17 files, +476 lines
- All 20 implementation commits verified

Feature branch ready for PR.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Add comprehensive documentation for KIND deployment and manual verification:
- QUICK_START.md: 30-second test commands
- KIND_CLUSTER_ACCESS.md: Complete cluster access guide
- DEPLOYMENT_SUMMARY.md: Full deployment details and results
- data-index/docs/verification/: E2E verification reports

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Signed-off-by: Ricardo Zanini <ricardozanini@gmail.com>
@ricardozanini ricardozanini merged commit 48033bb into main Apr 29, 2026
2 checks passed
@ricardozanini ricardozanini deleted the feature/unify-error-structure branch April 29, 2026 16:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant