Skip to content

refactor(comp.version): Implement error refactoring for Component Versions #904

@dorneanu

Description

@dorneanu

Task Description

Refactor ComponentVersion entity error handling to implement Google-style structured error pattern, following the proven approach from the completed Issue and ComponentInstance entity refactorings.

Acceptance Criteria

Application Layer (/internal/app/component_version/)

  • Refactor ListComponentVersions() method with structured error handling
  • Refactor CreateComponentVersion() method with structured error handling
  • Refactor UpdateComponentVersion() method with structured error handling
  • Refactor DeleteComponentVersion() method with structured error handling

Database Layer (/internal/database/mariadb/)

  • Refactor GetComponentVersions() method with structured error handling
  • Refactor GetAllComponentVersionIds() method with structured error handling
  • Refactor GetAllComponentVersionCursors() method with structured error handling
  • Refactor CountComponentVersions() method with structured error handling
  • Refactor CreateComponentVersion() method with structured error handling
  • Refactor UpdateComponentVersion() method with structured error handling
  • Refactor DeleteComponentVersion() method with structured error handling

API Layer (/internal/api/graphql/graph/baseResolver/)

  • Refactor SingleComponentVersionBaseResolver() method with structured error handling
  • Refactor ComponentVersionBaseResolver() method with structured error handling
  • Replace NewResolverError() calls with proper error handling and propagation
  • Ensure structured errors are properly converted to GraphQL errors

Implementation Requirements

  • Replace NewComponentVersionHandlerError() with appErrors.E() constructor
  • Use appErrors.Op() for operation context tracking
  • Implement proper error codes (InvalidArgument, NotFound, Internal)
  • Add contextual logging with logrus.Fields
  • Maintain comprehensive test coverage for error scenarios
  • Follow patterns established in Issue and ComponentInstance entity refactorings
  • Handle database-specific errors (duplicate entry, constraint violations, etc.)
  • Ensure proper error propagation from database → app → API layers

Acceptance Criterias

  • All tests pass after refactoring
  • Zero compilation errors (BLOCKED by unrelated component_instance.go Printf formatting issue)
  • Remove legacy ComponentVersionHandlerError type
  • Consistent error message formatting across all layers

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions