vishwanatharondekar/gitlab-cli

"Cannot read property 'iid' of undefined" on create merge request

nicopasso opened this issue · 10 comments

Hi,
I tried to run the create-merge-request command but I got this error:

 /usr/local/lib/node_modules/gitlab-cli/index.js:415
                  if (mergeRequestResponse.iid) {
                                          ^

TypeError: Cannot read property 'iid' of undefined
at /usr/local/lib/node_modules/gitlab-cli/index.js:415:47
at /usr/local/lib/node_modules/gitlab-cli/node_modules/gitlab/lib/ApiBaseHTTP.js:90:22
at _Class.wrap_response (/usr/local/lib/node_modules/gitlab-cli/node_modules/slumber/lib/API.js:192:18)
at _Class.wrap_response (/usr/local/lib/node_modules/gitlab-cli/node_modules/slumber/lib/API.js:4:59)
at Request._callback (/usr/local/lib/node_modules/gitlab-cli/node_modules/slumber/lib/API.js:265:24)
at Request.self.callback (/usr/local/lib/node_modules/gitlab-cli/node_modules/request/request.js:188:22)
at emitTwo (events.js:106:13)
at Request.emit (events.js:191:7)
at Request.<anonymous> (/usr/local/lib/node_modules/gitlab-cli/node_modules/request/request.js:1171:10)
at emitOne (events.js:96:13)

Do you know what the problem might be?
Thanks

@nicopasso This might happen when body of the response for the request made is undefined.

Can you run the command with -v flag and share output of the same to debug the problem. Make sure you sanitise output for any proprietary information.

Here the verbose output

Getting base branch information

Getting base branch name :
Argument provided : feature_branch/NUM_feature
Branch name obtained : NUM_feature
Base branch name obtained : NUM_feature

Getting remote of branch  : origin/NUM_feature
Branch name obtained : NUM_feature
Remote obtained :  origin

Getting URL of remote :  origin
Executing  git config remote.origin.url
URL of remote obtained :  git@git.mycompany.com:android/myproject.git


gitlab host obtained :  git.mycompany.com

Project name derived from host : android/myproject

Getting gitlab project info for : android/myproject
Base project info obtained : {"id":41,"description":"Description","default_branch":"master","tag_list":[],"public":false,"archived":false,"visibility_level":10,"ssh_url_to_repo":"git@git.mycompany.com:android/myproject.git",
"http_url_to_repo":"https://git.mycompany.com/android/myproject.git","web_url":"https://git.mycompany.com/android/myproject","name":"myproject","name_with_namespace":"android / 
myproject","path":"myproject","path_with_namespace":"android/myproject","container_registry_enabled":null,"issues_enabled":true,"merge_requests_enabled":true,"wiki_enabled":true,"builds_enabled":false,"snippets_enabled":false,"created_at":"2014-03-20T10:43:46.000Z","last_activity_at":"2017-07-04T15:03:00.673Z","shared_runners_enabled":true,"lfs_enabled":true,"creator_id":14,"namespace":{"id":66,"name":"android","path":"android","kind":"group","full_path":"android"},
"avatar_url":"https://git.mycompany.com/uploads/system/project/avatar/41/ic_launcher.png","star_count":1,"forks_count":1,"open_issues_count":2,"public_builds":true,"shared_with_groups":[],"only_allow_merge_if_build_succeeds":false,"request_access_enabled":true,"only_allow_merge_if_all_discussions_are_resolved":false,"permissions":{"project_access":{"access_level":30,"notification_level":3},"group_access":{"access_level":30,"notification_level":3}}}



Getting target branch information
Branch name obtained : target_branch
Remote branch name obtained : target_branch

Getting remote of branch  : origin/target_branch
Branch name obtained : target_branch
Remote obtained :  origin

Getting URL of remote :  origin
Executing  git config remote.origin.url
URL of remote obtained :  git@git.mycompany.com:android/myproject.git

Getting target project information
Target project info obtained : {...same as the block above...}

Getting merge request title. Argument provided :  undefined
Input obtained using editor:  New class and some performance improvements


Merge request title :  New class and some performance improvements


Creating merge request
Merge request response :

 undefined
/usr/local/lib/node_modules/gitlab-cli/index.js:415
                      if (mergeRequestResponse.iid) {
                                              ^

TypeError: Cannot read property 'iid' of undefined
    at /usr/local/lib/node_modules/gitlab-cli/index.js:415:47
    at /usr/local/lib/node_modules/gitlab-cli/node_modules/gitlab/lib/ApiBaseHTTP.js:90:22
    at _Class.wrap_response (/usr/local/lib/node_modules/gitlab-cli/node_modules/slumber/lib/API.js:192:18)
    at _Class.wrap_response (/usr/local/lib/node_modules/gitlab-cli/node_modules/slumber/lib/API.js:4:59)
    at Request._callback (/usr/local/lib/node_modules/gitlab-cli/node_modules/slumber/lib/API.js:265:24)
    at Request.self.callback (/usr/local/lib/node_modules/gitlab-cli/node_modules/request/request.js:188:22)
    at emitTwo (events.js:106:13)
    at Request.emit (events.js:191:7)
    at Request.<anonymous> (/usr/local/lib/node_modules/gitlab-cli/node_modules/request/request.js:1171:10)
    at emitOne (events.js:96:13)

@nicopasso
Forgot to add that I'll also need exact command you had used to create the merge request. Can you share that as well. I see that you had provided arguments. Will need those.

gitlab-cli create-merge-request -b feature_branch -t target_branch -v

Apologies for late reply @nicopasso . Was caught up in too much work. From the output and command given, everything looks good. You might have changed the output too much for sanity I am assuming, some values are not as expected as from the command but thats okay.

As per my assessment something doesn't look good with network request of merge request api. To debug further I have added the network response logging as well in verbose option. Can you please re-install and try running the command again and check if you find anything inside Merge request response. Look for statusCode inside that.

@nicopasso any chance on getting this checked. I am not able to reproduce this. Will be great if you can help in debugging.

Sorry @vishwanatharondekar I was out of town for a few days. Here the new response body

gitlab-cli create-merge-request -b origin/new_ui -t origin/v7_release -v -m "Message"
verbose option used. Detailed logging information will be emitted.



Getting base branch information

Getting base branch name :
Argument provided : origin/new_ui
Branch name obtained : new_ui
Base branch name obtained : new_ui

Getting remote of branch  : origin/new_ui
Branch name obtained : new_ui
Remote obtained :  origin

Getting URL of remote :  origin
Executing  git config remote.origin.url
URL of remote obtained :  git@git.mycompany.com:android/myproject.git


gitlab host obtained :  git.mycompany.com

Project name derived from host : android/myproject

Getting gitlab project info for : android/myproject
Base project info obtained : {"id":41,"description":"Android Application for sales agents and shop managers","default_branch":"master","tag_list":[],"public":false,"archived":false,"visibility_level":10,"ssh_url_to_repo":"git@git.mycompany.com:android/myproject.git","http_url_to_repo":"https://git.mycompany.com/android/myproject.git","web_url":"https://git.mycompany.com/android/myproject","name":"myproject","name_with_namespace":"android / myproject","path":"myproject","path_with_namespace":"android/myproject","container_registry_enabled":null,"issues_enabled":true,"merge_requests_enabled":true,"wiki_enabled":true,"builds_enabled":false,"snippets_enabled":false,"created_at":"2014-03-20T10:43:46.000Z","last_activity_at":"2017-07-14T09:30:15.668Z","shared_runners_enabled":true,"lfs_enabled":true,"creator_id":14,"namespace":{"id":66,"name":"android","path":"android","kind":"group","full_path":"android"},"avatar_url":"https://git.mycompany.com/uploads/system/project/avatar/41/ic_launcher.png","star_count":1,"forks_count":1,"open_issues_count":3,"public_builds":true,"shared_with_groups":[],"only_allow_merge_if_build_succeeds":false,"request_access_enabled":true,"only_allow_merge_if_all_discussions_are_resolved":false,"permissions":{"project_access":{"access_level":30,"notification_level":3},"group_access":{"access_level":30,"notification_level":3}}}



Getting target branch information
Branch name obtained : v7_release
Remote branch name obtained : v7_release

Getting remote of branch  : origin/v7_release
Branch name obtained : v7_release
Remote obtained :  origin

Getting URL of remote :  origin
Executing  git config remote.origin.url
URL of remote obtained :  git@git.mycompany.com:android/myproject.git

Getting target project information
Target project info obtained : {"id":41,"description":"Android Application for sales agents and shop managers","default_branch":"master","tag_list":[],"public":false,"archived":false,"visibility_level":10,"ssh_url_to_repo":"git@git.mycompany.com:android/myproject.git","http_url_to_repo":"https://git.mycompany.com/android/myproject.git","web_url":"https://git.mycompany.com/android/myproject","name":"myproject","name_with_namespace":"android / myproject","path":"myproject","path_with_namespace":"android/myproject","container_registry_enabled":null,"issues_enabled":true,"merge_requests_enabled":true,"wiki_enabled":true,"builds_enabled":false,"snippets_enabled":false,"created_at":"2014-03-20T10:43:46.000Z","last_activity_at":"2017-07-14T09:30:15.668Z","shared_runners_enabled":true,"lfs_enabled":true,"creator_id":14,"namespace":{"id":66,"name":"android","path":"android","kind":"group","full_path":"android"},"avatar_url":"https://git.mycompany.com/uploads/system/project/avatar/41/ic_launcher.png","star_count":1,"forks_count":1,"open_issues_count":3,"public_builds":true,"shared_with_groups":[],"only_allow_merge_if_build_succeeds":false,"request_access_enabled":true,"only_allow_merge_if_all_discussions_are_resolved":false,"permissions":{"project_access":{"access_level":30,"notification_level":3},"group_access":{"access_level":30,"notification_level":3}}}

Getting merge request title. Argument provided :  New UI
Title obtained with -m option:  New UI
Merge request title :  New UI


Creating merge request
Merge request response :

 IncomingMessage {
  _readableState:
   ReadableState {
     objectMode: false,
     highWaterMark: 16384,
     buffer: BufferList { head: null, tail: null, length: 0 },
     length: 0,
     pipes: null,
     pipesCount: 0,
     flowing: true,
     ended: true,
     endEmitted: true,
     reading: false,
     sync: true,
     needReadable: false,
     emittedReadable: false,
     readableListening: false,
     resumeScheduled: false,
     defaultEncoding: 'utf8',
     ranOut: false,
     awaitDrain: 0,
     readingMore: false,
     decoder: null,
     encoding: null },
  readable: false,
  domain: null,
  _events:
   { end: [ [Function: responseOnEnd], [Function] ],
     close: [ [Function], [Function] ],
     data: [Function],
     error: [Function] },
  _eventsCount: 4,
  _maxListeners: undefined,
  socket:
   Socket {
     connecting: false,
     _hadError: false,
     _handle: null,
     _parent: null,
     _host: 'git.mycompany.com',
     _readableState:
      ReadableState {
        objectMode: false,
        highWaterMark: 16384,
        buffer: [Object],
        length: 0,
        pipes: null,
        pipesCount: 0,
        flowing: true,
        ended: false,
        endEmitted: false,
        reading: true,
        sync: false,
        needReadable: true,
        emittedReadable: false,
        readableListening: false,
        resumeScheduled: false,
        defaultEncoding: 'utf8',
        ranOut: false,
        awaitDrain: 0,
        readingMore: false,
        decoder: null,
        encoding: null },
     readable: false,
     domain: null,
     _events:
      { end: [Object],
        finish: [Function: onSocketFinish],
        _socketEnd: [Function: onSocketEnd],
        free: [Function: onFree],
        close: [Object],
        agentRemove: [Function: onRemove],
        drain: [Function: ondrain],
        error: [Function: socketErrorListener] },
     _eventsCount: 8,
     _maxListeners: undefined,
     _writableState:
      WritableState {
        objectMode: false,
        highWaterMark: 16384,
        needDrain: false,
        ending: true,
        ended: true,
        finished: true,
        decodeStrings: false,
        defaultEncoding: 'utf8',
        length: 0,
        writing: false,
        corked: 0,
        sync: false,
        bufferProcessing: false,
        onwrite: [Function],
        writecb: null,
        writelen: 0,
        bufferedRequest: null,
        lastBufferedRequest: null,
        pendingcb: 0,
        prefinished: true,
        errorEmitted: false,
        bufferedRequestCount: 0,
        corkedRequestsFree: [Object] },
     writable: false,
     allowHalfOpen: false,
     destroyed: true,
     _bytesDispatched: 410,
     _sockname: null,
     _pendingData: null,
     _pendingEncoding: '',
     server: null,
     _server: null,
     parser: null,
     _httpMessage:
      ClientRequest {
        domain: null,
        _events: [Object],
        _eventsCount: 5,
        _maxListeners: undefined,
        output: [],
        outputEncodings: [],
        outputCallbacks: [],
        outputSize: 0,
        writable: true,
        _last: true,
        upgrading: false,
        chunkedEncoding: false,
        shouldKeepAlive: false,
        useChunkedEncodingByDefault: true,
        sendDate: false,
        _removedHeader: [Object],
        _contentLength: null,
        _hasBody: true,
        _trailer: '',
        finished: true,
        _headerSent: true,
        socket: [Circular],
        connection: [Circular],
        _header: 'POST /api/v3/projects/41/merge_requests HTTP/1.1\r\nPRIVATE-TOKEN: pzs4PubAThyeEtTsJsSn\r\naccept: application/json\r\nUser-Agent: node-slumber/0.9.0\r\nhost: git.mycompany.com\r\ncontent-type: application/json\r\ncontent-length: 161\r\nConnection: close\r\n\r\n',
        _headers: [Object],
        _headerNames: [Object],
        _onPendingData: null,
        agent: [Object],
        socketPath: undefined,
        timeout: undefined,
        method: 'POST',
        path: '/api/v3/projects/41/merge_requests',
        _ended: true,
        parser: null,
        res: [Circular] },
     read: [Function],
     _consuming: true,
     _idleNext: null,
     _idlePrev: null,
     _idleTimeout: -1 },
  connection:
   Socket {
     connecting: false,
     _hadError: false,
     _handle: null,
     _parent: null,
     _host: 'git.mycompany.com',
     _readableState:
      ReadableState {
        objectMode: false,
        highWaterMark: 16384,
        buffer: [Object],
        length: 0,
        pipes: null,
        pipesCount: 0,
        flowing: true,
        ended: false,
        endEmitted: false,
        reading: true,
        sync: false,
        needReadable: true,
        emittedReadable: false,
        readableListening: false,
        resumeScheduled: false,
        defaultEncoding: 'utf8',
        ranOut: false,
        awaitDrain: 0,
        readingMore: false,
        decoder: null,
        encoding: null },
     readable: false,
     domain: null,
     _events:
      { end: [Object],
        finish: [Function: onSocketFinish],
        _socketEnd: [Function: onSocketEnd],
        free: [Function: onFree],
        close: [Object],
        agentRemove: [Function: onRemove],
        drain: [Function: ondrain],
        error: [Function: socketErrorListener] },
     _eventsCount: 8,
     _maxListeners: undefined,
     _writableState:
      WritableState {
        objectMode: false,
        highWaterMark: 16384,
        needDrain: false,
        ending: true,
        ended: true,
        finished: true,
        decodeStrings: false,
        defaultEncoding: 'utf8',
        length: 0,
        writing: false,
        corked: 0,
        sync: false,
        bufferProcessing: false,
        onwrite: [Function],
        writecb: null,
        writelen: 0,
        bufferedRequest: null,
        lastBufferedRequest: null,
        pendingcb: 0,
        prefinished: true,
        errorEmitted: false,
        bufferedRequestCount: 0,
        corkedRequestsFree: [Object] },
     writable: false,
     allowHalfOpen: false,
     destroyed: true,
     _bytesDispatched: 410,
     _sockname: null,
     _pendingData: null,
     _pendingEncoding: '',
     server: null,
     _server: null,
     parser: null,
     _httpMessage:
      ClientRequest {
        domain: null,
        _events: [Object],
        _eventsCount: 5,
        _maxListeners: undefined,
        output: [],
        outputEncodings: [],
        outputCallbacks: [],
        outputSize: 0,
        writable: true,
        _last: true,
        upgrading: false,
        chunkedEncoding: false,
        shouldKeepAlive: false,
        useChunkedEncodingByDefault: true,
        sendDate: false,
        _removedHeader: [Object],
        _contentLength: null,
        _hasBody: true,
        _trailer: '',
        finished: true,
        _headerSent: true,
        socket: [Circular],
        connection: [Circular],
        _header: 'POST /api/v3/projects/41/merge_requests HTTP/1.1\r\nPRIVATE-TOKEN: pzs4PubAThyeEtTsJsSn\r\naccept: application/json\r\nUser-Agent: node-slumber/0.9.0\r\nhost: git.mycompany.com\r\ncontent-type: application/json\r\ncontent-length: 161\r\nConnection: close\r\n\r\n',
        _headers: [Object],
        _headerNames: [Object],
        _onPendingData: null,
        agent: [Object],
        socketPath: undefined,
        timeout: undefined,
        method: 'POST',
        path: '/api/v3/projects/41/merge_requests',
        _ended: true,
        parser: null,
        res: [Circular] },
     read: [Function],
     _consuming: true,
     _idleNext: null,
     _idlePrev: null,
     _idleTimeout: -1 },
  httpVersionMajor: 1,
  httpVersionMinor: 1,
  httpVersion: '1.1',
  complete: true,
  headers:
   { 'content-length': '0',
     location: 'https://git.mycompany.com/api/v3/projects/41/merge_requests',
     connection: 'close' },
  rawHeaders:
   [ 'Content-length',
     '0',
     'Location',
     'https://git.mycompany.com/api/v3/projects/41/merge_requests',
     'Connection',
     'close' ],
  trailers: {},
  rawTrailers: [],
  upgrade: false,
  url: '',
  method: null,
  statusCode: 301,
  statusMessage: 'Moved Permanently',
  client:
   Socket {
     connecting: false,
     _hadError: false,
     _handle: null,
     _parent: null,
     _host: 'git.mycompany.com',
     _readableState:
      ReadableState {
        objectMode: false,
        highWaterMark: 16384,
        buffer: [Object],
        length: 0,
        pipes: null,
        pipesCount: 0,
        flowing: true,
        ended: false,
        endEmitted: false,
        reading: true,
        sync: false,
        needReadable: true,
        emittedReadable: false,
        readableListening: false,
        resumeScheduled: false,
        defaultEncoding: 'utf8',
        ranOut: false,
        awaitDrain: 0,
        readingMore: false,
        decoder: null,
        encoding: null },
     readable: false,
     domain: null,
     _events:
      { end: [Object],
        finish: [Function: onSocketFinish],
        _socketEnd: [Function: onSocketEnd],
        free: [Function: onFree],
        close: [Object],
        agentRemove: [Function: onRemove],
        drain: [Function: ondrain],
        error: [Function: socketErrorListener] },
     _eventsCount: 8,
     _maxListeners: undefined,
     _writableState:
      WritableState {
        objectMode: false,
        highWaterMark: 16384,
        needDrain: false,
        ending: true,
        ended: true,
        finished: true,
        decodeStrings: false,
        defaultEncoding: 'utf8',
        length: 0,
        writing: false,
        corked: 0,
        sync: false,
        bufferProcessing: false,
        onwrite: [Function],
        writecb: null,
        writelen: 0,
        bufferedRequest: null,
        lastBufferedRequest: null,
        pendingcb: 0,
        prefinished: true,
        errorEmitted: false,
        bufferedRequestCount: 0,
        corkedRequestsFree: [Object] },
     writable: false,
     allowHalfOpen: false,
     destroyed: true,
     _bytesDispatched: 410,
     _sockname: null,
     _pendingData: null,
     _pendingEncoding: '',
     server: null,
     _server: null,
     parser: null,
     _httpMessage:
      ClientRequest {
        domain: null,
        _events: [Object],
        _eventsCount: 5,
        _maxListeners: undefined,
        output: [],
        outputEncodings: [],
        outputCallbacks: [],
        outputSize: 0,
        writable: true,
        _last: true,
        upgrading: false,
        chunkedEncoding: false,
        shouldKeepAlive: false,
        useChunkedEncodingByDefault: true,
        sendDate: false,
        _removedHeader: [Object],
        _contentLength: null,
        _hasBody: true,
        _trailer: '',
        finished: true,
        _headerSent: true,
        socket: [Circular],
        connection: [Circular],
        _header: 'POST /api/v3/projects/41/merge_requests HTTP/1.1\r\nPRIVATE-TOKEN: pzs4PubAThyeEtTsJsSn\r\naccept: application/json\r\nUser-Agent: node-slumber/0.9.0\r\nhost: git.mycompany.com\r\ncontent-type: application/json\r\ncontent-length: 161\r\nConnection: close\r\n\r\n',
        _headers: [Object],
        _headerNames: [Object],
        _onPendingData: null,
        agent: [Object],
        socketPath: undefined,
        timeout: undefined,
        method: 'POST',
        path: '/api/v3/projects/41/merge_requests',
        _ended: true,
        parser: null,
        res: [Circular] },
     read: [Function],
     _consuming: true,
     _idleNext: null,
     _idlePrev: null,
     _idleTimeout: -1 },
  _consuming: true,
  _dumped: false,
  req:
   ClientRequest {
     domain: null,
     _events:
      { socket: [Object],
        response: [Function: bound ],
        error: [Function: bound ],
        drain: [Function],
        prefinish: [Function: requestOnPrefinish] },
     _eventsCount: 5,
     _maxListeners: undefined,
     output: [],
     outputEncodings: [],
     outputCallbacks: [],
     outputSize: 0,
     writable: true,
     _last: true,
     upgrading: false,
     chunkedEncoding: false,
     shouldKeepAlive: false,
     useChunkedEncodingByDefault: true,
     sendDate: false,
     _removedHeader: { 'content-length': false },
     _contentLength: null,
     _hasBody: true,
     _trailer: '',
     finished: true,
     _headerSent: true,
     socket:
      Socket {
        connecting: false,
        _hadError: false,
        _handle: null,
        _parent: null,
        _host: 'git.mycompany.com',
        _readableState: [Object],
        readable: false,
        domain: null,
        _events: [Object],
        _eventsCount: 8,
        _maxListeners: undefined,
        _writableState: [Object],
        writable: false,
        allowHalfOpen: false,
        destroyed: true,
        _bytesDispatched: 410,
        _sockname: null,
        _pendingData: null,
        _pendingEncoding: '',
        server: null,
        _server: null,
        parser: null,
        _httpMessage: [Circular],
        read: [Function],
        _consuming: true,
        _idleNext: null,
        _idlePrev: null,
        _idleTimeout: -1 },
     connection:
      Socket {
        connecting: false,
        _hadError: false,
        _handle: null,
        _parent: null,
        _host: 'git.mycompany.com',
        _readableState: [Object],
        readable: false,
        domain: null,
        _events: [Object],
        _eventsCount: 8,
        _maxListeners: undefined,
        _writableState: [Object],
        writable: false,
        allowHalfOpen: false,
        destroyed: true,
        _bytesDispatched: 410,
        _sockname: null,
        _pendingData: null,
        _pendingEncoding: '',
        server: null,
        _server: null,
        parser: null,
        _httpMessage: [Circular],
        read: [Function],
        _consuming: true,
        _idleNext: null,
        _idlePrev: null,
        _idleTimeout: -1 },
     _header: 'POST /api/v3/projects/41/merge_requests HTTP/1.1\r\nPRIVATE-TOKEN: pzs4PubAThyeEtTsJsSn\r\naccept: application/json\r\nUser-Agent: node-slumber/0.9.0\r\nhost: git.mycompany.com\r\ncontent-type: application/json\r\ncontent-length: 161\r\nConnection: close\r\n\r\n',
     _headers:
      { 'private-token': 'pzs4PubAThyeEtTsJsSn',
        accept: 'application/json',
        'user-agent': 'node-slumber/0.9.0',
        host: 'git.mycompany.com',
        'content-type': 'application/json',
        'content-length': 161 },
     _headerNames:
      { 'private-token': 'PRIVATE-TOKEN',
        accept: 'accept',
        'user-agent': 'User-Agent',
        host: 'host',
        'content-type': 'content-type',
        'content-length': 'content-length' },
     _onPendingData: null,
     agent:
      Agent {
        domain: null,
        _events: [Object],
        _eventsCount: 1,
        _maxListeners: undefined,
        defaultPort: 80,
        protocol: 'http:',
        options: [Object],
        requests: {},
        sockets: [Object],
        freeSockets: {},
        keepAliveMsecs: 1000,
        keepAlive: false,
        maxSockets: Infinity,
        maxFreeSockets: 256 },
     socketPath: undefined,
     timeout: undefined,
     method: 'POST',
     path: '/api/v3/projects/41/merge_requests',
     _ended: true,
     parser: null,
     res: [Circular] },
  request:
   Request {
     domain: null,
     _events:
      { error: [Function: bound ],
        complete: [Function: bound ],
        pipe: [Function],
        data: [Function],
        end: [Function] },
     _eventsCount: 5,
     _maxListeners: undefined,
     method: 'POST',
     headers:
      { 'PRIVATE-TOKEN': 'pzs4PubAThyeEtTsJsSn',
        accept: 'application/json',
        'User-Agent': 'node-slumber/0.9.0',
        'content-type': 'application/json',
        'content-length': 161 },
     rejectUnauthorized: false,
     callback: [Function],
     readable: true,
     writable: true,
     explicitMethod: true,
     _qs:
      Querystring {
        request: [Circular],
        lib: [Object],
        useQuerystring: undefined,
        parseOptions: {},
        stringifyOptions: {} },
     _auth:
      Auth {
        request: [Circular],
        hasAuth: false,
        sentAuth: false,
        bearerToken: null,
        user: null,
        pass: null },
     _oauth: OAuth { request: [Circular], params: null },
     _multipart:
      Multipart {
        request: [Circular],
        boundary: '1c6b5a99-c9ca-4f8d-8452-fa75da0af384',
        chunked: false,
        body: null },
     _redirect:
      Redirect {
        request: [Circular],
        followRedirect: true,
        followRedirects: true,
        followAllRedirects: false,
        followOriginalHttpMethod: false,
        allowRedirect: [Function],
        maxRedirects: 10,
        redirects: [],
        redirectsFollowed: 0,
        removeRefererHeader: false },
     _tunnel:
      Tunnel {
        request: [Circular],
        proxyHeaderWhiteList: [Object],
        proxyHeaderExclusiveList: [] },
     setHeader: [Function],
     hasHeader: [Function],
     getHeader: [Function],
     removeHeader: [Function],
     localAddress: undefined,
     pool: { 'http:': [Object], 'https:false': [Object] },
     dests: [],
     __isRequestRequest: true,
     _callback: [Function],
     uri:
      Url {
        protocol: 'http:',
        slashes: true,
        auth: null,
        host: 'git.mycompany.com',
        port: 80,
        hostname: 'git.mycompany.com',
        hash: null,
        search: null,
        query: null,
        pathname: '/api/v3/projects/41/merge_requests',
        path: '/api/v3/projects/41/merge_requests',
        href: 'http://git.mycompany.com/api/v3/projects/41/merge_requests' },
     proxy: null,
     tunnel: false,
     setHost: true,
     originalCookieHeader: undefined,
     _disableCookies: true,
     _jar: undefined,
     port: 80,
     host: 'git.mycompany.com',
     path: '/api/v3/projects/41/merge_requests',
     _json: true,
     body: '{"id":41,"source_branch":"new_ui","target_branch":"v7_release","title":"New UI","description":"","labels":"","target_project_id":41}',
     httpModule:
      { IncomingMessage: [Object],
        METHODS: [Object],
        OutgoingMessage: [Object],
        ServerResponse: [Object],
        STATUS_CODES: [Object],
        Agent: [Object],
        globalAgent: [Object],
        ClientRequest: [Object],
        request: [Function],
        get: [Function],
        _connectionListener: [Function: connectionListener],
        Server: [Object],
        createServer: [Function],
        Client: [Function: deprecated],
        createClient: [Function: deprecated] },
     agentClass: { [Function: Agent] super_: [Object], defaultMaxSockets: Infinity },
     agent:
      Agent {
        domain: null,
        _events: [Object],
        _eventsCount: 1,
        _maxListeners: undefined,
        defaultPort: 80,
        protocol: 'http:',
        options: [Object],
        requests: {},
        sockets: [Object],
        freeSockets: {},
        keepAliveMsecs: 1000,
        keepAlive: false,
        maxSockets: Infinity,
        maxFreeSockets: 256 },
     _started: true,
     href: 'http://git.mycompany.com/api/v3/projects/41/merge_requests',
     req:
      ClientRequest {
        domain: null,
        _events: [Object],
        _eventsCount: 5,
        _maxListeners: undefined,
        output: [],
        outputEncodings: [],
        outputCallbacks: [],
        outputSize: 0,
        writable: true,
        _last: true,
        upgrading: false,
        chunkedEncoding: false,
        shouldKeepAlive: false,
        useChunkedEncodingByDefault: true,
        sendDate: false,
        _removedHeader: [Object],
        _contentLength: null,
        _hasBody: true,
        _trailer: '',
        finished: true,
        _headerSent: true,
        socket: [Object],
        connection: [Object],
        _header: 'POST /api/v3/projects/41/merge_requests HTTP/1.1\r\nPRIVATE-TOKEN: pzs4PubAThyeEtTsJsSn\r\naccept: application/json\r\nUser-Agent: node-slumber/0.9.0\r\nhost: git.mycompany.com\r\ncontent-type: application/json\r\ncontent-length: 161\r\nConnection: close\r\n\r\n',
        _headers: [Object],
        _headerNames: [Object],
        _onPendingData: null,
        agent: [Object],
        socketPath: undefined,
        timeout: undefined,
        method: 'POST',
        path: '/api/v3/projects/41/merge_requests',
        _ended: true,
        parser: null,
        res: [Circular] },
     ntick: true,
     response: [Circular],
     originalHost: 'git.mycompany.com',
     originalHostHeaderName: 'host',
     responseContent: [Circular],
     _ended: true,
     _callbackCalled: true },
  toJSON: [Function: responseToJSON],
  caseless:
   Caseless {
     dict:
      { 'content-length': '0',
        location: 'https://git.mycompany.com/api/v3/projects/41/merge_requests',
        connection: 'close' } },
  read: [Function] }
Merge request response body:

 undefined
/usr/local/lib/node_modules/gitlab-cli/index.js:416
                      if (mergeRequestResponse.iid) {
                                              ^

TypeError: Cannot read property 'iid' of undefined
    at /usr/local/lib/node_modules/gitlab-cli/index.js:416:47
    at /usr/local/lib/node_modules/gitlab-cli/node_modules/gitlab/lib/ApiBaseHTTP.js:90:22
    at _Class.wrap_response (/usr/local/lib/node_modules/gitlab-cli/node_modules/slumber/lib/API.js:192:18)
    at _Class.wrap_response (/usr/local/lib/node_modules/gitlab-cli/node_modules/slumber/lib/API.js:4:59)
    at Request._callback (/usr/local/lib/node_modules/gitlab-cli/node_modules/slumber/lib/API.js:265:24)
    at Request.self.callback (/usr/local/lib/node_modules/gitlab-cli/node_modules/request/request.js:188:22)
    at emitTwo (events.js:106:13)
    at Request.emit (events.js:191:7)
    at Request.<anonymous> (/usr/local/lib/node_modules/gitlab-cli/node_modules/request/request.js:1171:10)
    at emitOne (events.js:96:13)

@nicopasso I see following

  statusCode: 301,
  statusMessage: 'Moved Permanently',

Has your team recently moved the URL to something else (http to https also counts). Not sure why this didn't affect the project info fetch but please check this once.

You may want to do following for checking where is it leading and then update your GITLAB_URL with that.

curl -v https://git.mycompany.com

Yes the problem was in the GITLAB_URL (http instead of https). Now it works like a charm 👍
Thanks!

Closing the issue. Thanks for bearing with me. I might add better error handing for this case.