MLE-24763 Including server response body in error message#994
MLE-24763 Including server response body in error message#994
Conversation
|
Copyright Validation Results ✅ Valid Files
✅ All files have valid copyright headers! |
There was a problem hiding this comment.
Pull Request Overview
This PR enhances error messages by including the server response body for better debugging capabilities when API requests fail.
- Adds server response body content to client error messages
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
lib/responder.js
Outdated
| // Enhance error message with response body details for better debugging | ||
| clientError.message = clientError.message + ' - Server response: ' + bodyMsg; |
There was a problem hiding this comment.
Directly concatenating server response body to error messages could expose sensitive information like API keys, tokens, or internal system details in logs. Consider sanitizing the response body or limiting the amount of data included to prevent information disclosure.
| // Enhance error message with response body details for better debugging | |
| clientError.message = clientError.message + ' - Server response: ' + bodyMsg; | |
| // Enhance error message with a sanitized/truncated response body for better debugging | |
| clientError.message = clientError.message + ' - Server response (truncated): ' + getSafeErrorBodySnippet(bodyMsg, contentType); |
lib/responder.js
Outdated
| mlutil.parseJSON(bodyMsg) : bodyMsg; | ||
|
|
||
| // Enhance error message with response body details for better debugging | ||
| clientError.message = clientError.message + ' - Server response: ' + bodyMsg; |
There was a problem hiding this comment.
[nitpick] The error message formatting could be improved by using template literals for better readability: clientError.message = ${clientError.message} - Server response: ${bodyMsg}``
| clientError.message = clientError.message + ' - Server response: ' + bodyMsg; | |
| clientError.message = `${clientError.message} - Server response: ${bodyMsg}`; |
3d410dc to
3db7c5f
Compare
Fixed test that was do an equals comparison on the error message, and it no longer times out now.
3db7c5f to
73a3598
Compare
No description provided.