Skip to content

Commit

Permalink
Switch DELETE requests to 200 instead of 204 response code
Browse files Browse the repository at this point in the history
204 means no body, but we're returning a success message. This causes
echo server to print an error in the logs and the body gets dropped.
  • Loading branch information
Tehsmash authored and FrimIdan committed Mar 19, 2023
1 parent 0605e2d commit 06c5a00
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 34 deletions.
24 changes: 12 additions & 12 deletions api/client/client.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ paths:
parameters:
- $ref: '#/components/parameters/targetID'
responses:
204:
200:
$ref: '#/components/responses/Success'
404:
description: Target ID not found
Expand Down Expand Up @@ -362,7 +362,7 @@ paths:
parameters:
- $ref: '#/components/parameters/scanID'
responses:
204:
200:
$ref: '#/components/responses/Success'
404:
description: Scan ID not found
Expand Down Expand Up @@ -498,7 +498,7 @@ paths:
parameters:
- $ref: '#/components/parameters/scanConfigID'
responses:
204:
200:
$ref: '#/components/responses/Success'
404:
description: Scan config ID not found
Expand Down Expand Up @@ -668,7 +668,7 @@ paths:
parameters:
- $ref: '#/components/parameters/findingID'
responses:
204:
200:
$ref: '#/components/responses/Success'
404:
description: Finding ID not found
Expand Down
28 changes: 14 additions & 14 deletions api/server/server.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion backend/pkg/rest/findings_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func (s *ServerImpl) DeleteFindingsFindingID(ctx echo.Context, findingID models.
return sendError(ctx, http.StatusInternalServerError, err.Error())
}

return sendResponse(ctx, http.StatusNoContent, &success)
return sendResponse(ctx, http.StatusOK, &success)
}

func (s *ServerImpl) PatchFindingsFindingID(ctx echo.Context, findingID models.FindingID) error {
Expand Down
2 changes: 1 addition & 1 deletion backend/pkg/rest/scan_config_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func (s *ServerImpl) DeleteScanConfigsScanConfigID(ctx echo.Context, scanConfigI
return sendError(ctx, http.StatusInternalServerError, err.Error())
}

return sendResponse(ctx, http.StatusNoContent, &success)
return sendResponse(ctx, http.StatusOK, &success)
}

func (s *ServerImpl) PatchScanConfigsScanConfigID(ctx echo.Context, scanConfigID models.ScanConfigID) error {
Expand Down
2 changes: 1 addition & 1 deletion backend/pkg/rest/scan_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func (s *ServerImpl) DeleteScansScanID(ctx echo.Context, scanID models.ScanID) e
return sendError(ctx, http.StatusInternalServerError, fmt.Sprintf("failed to delete scan from db. scanID=%v: %v", scanID, err))
}

return sendResponse(ctx, http.StatusNoContent, &success)
return sendResponse(ctx, http.StatusOK, &success)
}

func (s *ServerImpl) GetScansScanID(ctx echo.Context, scanID models.ScanID, params models.GetScansScanIDParams) error {
Expand Down
2 changes: 1 addition & 1 deletion backend/pkg/rest/target_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,5 +110,5 @@ func (s *ServerImpl) DeleteTargetsTargetID(ctx echo.Context, targetID models.Tar
return sendError(ctx, http.StatusInternalServerError, fmt.Sprintf("failed to delete target from db. targetID=%v: %v", targetID, err))
}

return sendResponse(ctx, http.StatusNoContent, &success)
return sendResponse(ctx, http.StatusOK, &success)
}

0 comments on commit 06c5a00

Please sign in to comment.