Skip to content

fix: Error codes needs to be documented in Swagger - #2461

Closed
William-Hill wants to merge 1 commit into
ConduitIO:mainfrom
William-Hill:agent/fix-576-anthropic
Closed

fix: Error codes needs to be documented in Swagger#2461
William-Hill wants to merge 1 commit into
ConduitIO:mainfrom
William-Hill:agent/fix-576-anthropic

Conversation

@William-Hill

Copy link
Copy Markdown

Fixes #576

Agent Summary

Excellent! Everything compiles and the changes are in place. Let me create a summary of what was implemented:

Summary

I have successfully implemented all three files according to the implementation plan. Here's what was written:

1. pkg/pipeline/service.go (Modified)

  • Added imports: google.golang.org/grpc/codes and google.golang.org/grpc/status
  • Standardized error handling across all service methods:
    • Validation errors (e.g., ErrNameMissing, ErrInvalidCharacters, ErrDescriptionOverLimit) → codes.InvalidArgument
    • Name already exists errors → codes.AlreadyExists
    • Instance not found errors → codes.NotFound
    • Connector/Processor ID not found errors → codes.NotFound
    • DLQ configuration validation errors → codes.InvalidArgument
    • Internal/database errors → codes.Internal
  • Fixed variable naming conflict: Changed status variable to pipelineStatus in UpdateStatus and related helper methods to avoid shadowing the status package
  • All error returns now use status.Errorf() with appropriate gRPC codes, allowing gRPC-Gateway to automatically translate them to the correct HTTP status codes

2. pkg/connector/service.go (Modified)

  • Added imports: google.golang.org/grpc/codes and google.golang.org/grpc/status
  • Standardized error handling across all service methods:
    • Validation errors (e.g., ErrNameMissing, ErrInvalidCharacters) → codes.InvalidArgument
    • Invalid plugin/pipeline ID/type → codes.InvalidArgument
    • Instance not found errors → codes.NotFound
    • Processor ID not found errors → codes.NotFound
    • Invalid connector state type → codes.InvalidArgument
    • Internal/database errors → codes.Internal
  • All error returns now use status.Errorf() with appropriate gRPC codes
  • Improved error messages with contextual information

3. proto/api/v1/api.proto (Modified)

  • Added OpenAPI documentation for the UpdateDLQ RPC:
    • Documents HTTP 404 response with example code: 5 (NotFound)
    • Documents HTTP 400 response with example code: 3 (InvalidArgument) for DLQ configuration validation errors
  • The StartPipeline RPC already had the appropriate error response documentation in place

Build Verification

Build successful - go build ./... completes without errors

Key Benefits

  1. HTTP 400 Bad Request for validation failures - Client-side validation errors now correctly return HTTP 400 instead of HTTP 500

  2. Proper gRPC status codes - All errors are wrapped with appropriate gRPC codes that gRPC-Gateway translates to HTTP status codes:

    • InvalidArgument (3) → HTTP 400
    • NotFound (5) → HTTP 404
    • AlreadyExists (6) → HTTP 409
    • FailedPrecondition (9) → HTTP 400
    • Internal (13) → HTTP 500
  3. OpenAPI documentation - The Swagger/OpenAPI spec now explicitly documents expected error responses with examples

  4. Consistent error handling - Standardized approach across both services makes the codebase more maintainable


Generated by conduit-agent-experiment (archivist: Gemini Flash, implementer: claude-haiku-4-5, 13 iterations).

@William-Hill
William-Hill force-pushed the agent/fix-576-anthropic branch from 0f93d40 to 0bae7a4 Compare April 12, 2026 17:08
Fixes ConduitIO#576

Generated by conduit-agent-experiment implementer.
@William-Hill
William-Hill force-pushed the agent/fix-576-anthropic branch from 0bae7a4 to 3bcfaed Compare April 12, 2026 17:19
@William-Hill
William-Hill deleted the agent/fix-576-anthropic branch April 12, 2026 19:52
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.

Error codes needs to be documented in Swagger

1 participant