Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: as-promise.js should not silently fail, it should display the body of error responses to the user. #264

Open
EvanCarroll opened this issue Jul 27, 2021 · 0 comments

Comments

@EvanCarroll
Copy link

I am able to show that as-promise.js has a silent failure mode where the body of the request that results in an error is not displayed to the user.

This is not the right place to solve this problem, but I could prove the body was not being reflected to the user by modifying this,

const parseBody = (body, responseType, encoding) => {
    if (responseType === 'json') {
        return body.length === 0 ? '' : JSON.parse(body.toString());
    }
    if (responseType === 'buffer') {
        return Buffer.from(body);
    }
    if (responseType === 'text') {
        return body.toString(encoding);
    }
    throw new TypeError(`Unknown body type '${responseType}'`);
};
const parseBody = (body, responseType, encoding) => {
    console.log( {responseType, body: body.toString(encoding)} );

This gave me much needed contextual information about

[12:29:11 PM] [semantic-release] › ✖  An error occurred while running semantic-release: HTTPError: Response code 400 (Bad Request)
    at EventEmitter.<anonymous> (/home/ecarroll/n/lib/node_modules/@semantic-release/gitlab/node_modules/got/dist/source/as-promise.js:118:31)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:95:5) {
  pluginName: '@semantic-release/gitlab'
}
HTTPError: Response code 400 (Bad Request)
    at EventEmitter.<anonymous> (/home/ecarroll/n/lib/node_modules/@semantic-release/gitlab/node_modules/got/dist/source/as-promise.js:118:31)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:95:5) {
  pluginName: '@semantic-release/gitlab'
}%

this error, such that I could see,

{
  responseType: 'text',
  body: '{"message":"Validation failed: Links have duplicate values (cpanel-angular-validators.js) for #\\u003cRelease:0x00007f0702a43908\\u003e scope"}'
}```

**Note this ticket is for displaying the body of an error response to the user**
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
@EvanCarroll and others