pyrit.exceptions.handle_bad_request_exception#
- handle_bad_request_exception(response_text: str, request: MessagePiece, is_content_filter: bool = False, error_code: int = 400) Message[source]#
Handle bad request responses and map them to standardized error messages.
- Parameters:
response_text (str) – Raw response text from the target.
request (MessagePiece) – Original request piece that caused the error.
is_content_filter (bool) – Whether the response is known to be content-filtered.
error_code (int) – Status code to include in the generated error payload.
- Returns:
A constructed error response message.
- Return type:
- Raises:
RuntimeError – If the response does not match bad-request content-filter conditions.