prompt-injection icon indicating copy to clipboard operation
prompt-injection copied to clipboard

Send better error responses

Open gsproston-scottlogic opened this issue 2 years ago • 1 comments

Feature Request

Description

The "handleError" file contains a sendErrorResponse method, which takes an HTTP status code and an error message, and constructs and sends an HTTP response. This is only used in the defence/configure endpoint in the defence controller, but it'd be nice to use this in other endpoints.

This is a refactor ticket, don't add extra validation, just update existing validation. New validation is covered in #625 .

Acceptance criteria

Note this might require some use of Postman to manually send API requests to the backend.

GIVEN an API request is missing required query params WHEN the API request is sent THEN the API response has status code 400 AND the API response body contains an error message

GIVEN an API request is missing required body params WHEN the API request is sent THEN the API response has status code 400 AND the API response body contains an error message

GIVEN a valid API request is received on the backend WHEN the an error occurs server side THEN the API response has status code 500 AND the API response body contains an error message

gsproston-scottlogic avatar Nov 17 '23 11:11 gsproston-scottlogic

Updated with the correct file names, now that the controller refactor is done.

gsproston-scottlogic avatar Jan 05 '24 13:01 gsproston-scottlogic