Errors are not propagated via APIs properly
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 71
- Forks
- 111
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 110
Description
Please select the area the issue is related to
Area/Management (Management API or Management Portal UI)
Please select the aspect the issue is related to
Aspect/API (API backends, definitions, contracts, interfaces, OpenAPI)
Description
When errors are captured at downstream methods, they are ignored and new/generic errors are passed via the REST APIs making it hard to capture the orginal error.
Steps to Reproduce
- Create an API without backends
- Deploy it to a gateway
Error shown via the REST APIs:
{
"code": 400,
"message": "Bad Request",
"description": "Invalid API deployment configuration"
}
Actual error:
// validateDeploymentRequest validates the deployment request
func (s *APIService) validateDeploymentRequest(req *dto.APIRevisionDeployment, apiId, orgId string) error {
if req.GatewayID == "" {
return errors.New("gateway Id is required")
}
if req.VHost == "" {
return errors.New("vhost is required")
}
// TODO - vHost validation
gateway, err := s.gatewayRepo.GetByUUID(req.GatewayID)
if err != nil {
return fmt.Errorf("failed to get gateway: %w", err)
}
if gateway == nil {
return fmt.Errorf("failed to get gateway: %w", err)
}
if gateway.OrganizationID != orgId {
return fmt.Errorf("failed to get gateway: %w", err)
}
// Validate that the API has at least one backend service attached
backendServices, err := s.backendServiceRepo.GetBackendServicesByAPIID(apiId)
if err != nil {
return fmt.Errorf("failed to get backend services for API: %w", err)
}
if len(backendServices) == 0 { <<<<<<<<<<<<<<<<<
return errors.New("API must have at least one backend service attached before deployment")
}
Severity Level of the Issue
Severity/Major (Important functionality is broken. Should be prioritized. Doesn't need immediate attention)
Environment Details (with versions)
No response
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The reported path is APIService.validateDeploymentRequest, including gatewayRepo.GetByUUID and backendServiceRepo.GetBackendServicesByAPIID; start there and trace how returned errors become REST responses. Review the existing API error-response handling, then verify that downstream validation errors reach the API response with their useful message instead of a generic deployment error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 38/100