semantic-release / semantic-release/gitlab

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

Open
#264 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
344
Forks
89
Avg merge
16h 11m
Merged PRs (30d)
4

Description

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**

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Read the error path around parseBody in as-promise.js and trace how the semantic-release GitLab plugin surfaces HTTPError responses. Reproduce the reported 400 response and confirm that its response body is displayed to the user rather than silently omitted.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
release
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.