github-push-action icon indicating copy to clipboard operation
github-push-action copied to clipboard

Error: Invalid status code '404' for url 'https://api.github.com/repos/<user>/<repo>'

Open DatStorm opened this issue 4 years ago • 9 comments

Hey

I have some problems using push actions. First, no push would happen because of not pulled beforehand but found the solution to that. Now it can not access the GitHub API. I have set the GitHub token and everything. The Repo is private.

Error: Invalid status code '404' for url 'https://api.github.com/repos/<USER>/<REPO>'
    at IncomingMessage.<anonymous> (/home/runner/work/_actions/ad-m/github-push-action/master/start.js:14:21)
    at IncomingMessage.emit (events.js:215:7)
    at endReadableNT (_stream_readable.js:1184:12)
    at processTicksAndRejections (internal/process/task_queues.js:80:21) {
  res: 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,
      paused: false,
      emitClose: true,
      autoDestroy: false,
      destroyed: false,
      defaultEncoding: 'utf8',
      awaitDrain: 0,
      readingMore: true,
      decoder: null,
      encoding: null
    },
    readable: false,
    _events: [Object: null prototype] { end: [Array], data: [Function] },
    _eventsCount: 2,
    _maxListeners: undefined,
    socket: TLSSocket {
      _tlsOptions: [Object],
      _secureEstablished: true,
      _securePending: false,
      _newSessionPending: false,
      _controlReleased: true,
      _SNICallback: null,
      servername: 'api.github.com',
      alpnProtocol: false,
      authorized: true,
      authorizationError: null,
      encrypted: true,
      _events: [Object: null prototype],
      _eventsCount: 9,
      connecting: false,
      _hadError: false,
      _parent: null,
      _host: 'api.github.com',
      _readableState: [ReadableState],
      readable: true,
      _maxListeners: undefined,
      _writableState: [WritableState],
      writable: false,
      allowHalfOpen: false,
      _sockname: null,
      _pendingData: null,
      _pendingEncoding: '',
      server: undefined,
      _server: null,
      ssl: [TLSWrap],
      _requestCert: true,
      _rejectUnauthorized: true,
      parser: null,
      _httpMessage: [ClientRequest],
      [Symbol(res)]: [TLSWrap],
      [Symbol(asyncId)]: 3,
      [Symbol(kHandle)]: [TLSWrap],
      [Symbol(lastWriteQueueSize)]: 0,
      [Symbol(timeout)]: null,
      [Symbol(kBuffer)]: null,
      [Symbol(kBufferCb)]: null,
      [Symbol(kBufferGen)]: null,
      [Symbol(kBytesRead)]: 0,
      [Symbol(kBytesWritten)]: 0,
      [Symbol(connect-options)]: [Object]
    },
    connection: TLSSocket {
      _tlsOptions: [Object],
      _secureEstablished: true,
      _securePending: false,
      _newSessionPending: false,
      _controlReleased: true,
      _SNICallback: null,
      servername: 'api.github.com',
      alpnProtocol: false,
      authorized: true,
      authorizationError: null,
      encrypted: true,
      _events: [Object: null prototype],
      _eventsCount: 9,
      connecting: false,
      _hadError: false,
      _parent: null,
      _host: 'api.github.com',
      _readableState: [ReadableState],
      readable: true,
      _maxListeners: undefined,
      _writableState: [WritableState],
      writable: false,
      allowHalfOpen: false,
      _sockname: null,
      _pendingData: null,
      _pendingEncoding: '',
      server: undefined,
      _server: null,
      ssl: [TLSWrap],
      _requestCert: true,
      _rejectUnauthorized: true,
      parser: null,
      _httpMessage: [ClientRequest],
      [Symbol(res)]: [TLSWrap],
      [Symbol(asyncId)]: 3,
      [Symbol(kHandle)]: [TLSWrap],
      [Symbol(lastWriteQueueSize)]: 0,
      [Symbol(timeout)]: null,
      [Symbol(kBuffer)]: null,
      [Symbol(kBufferCb)]: null,
      [Symbol(kBufferGen)]: null,
      [Symbol(kBytesRead)]: 0,
      [Symbol(kBytesWritten)]: 0,
      [Symbol(connect-options)]: [Object]
    },
    httpVersionMajor: 1,
    httpVersionMinor: 1,
    httpVersion: '1.1',
    complete: true,
    headers: {
      server: 'GitHub.com',
      date: 'Tue, 05 Jan 2021 06:13:21 GMT',
      'content-type': 'application/json; charset=utf-8',
      status: '404 Not Found',
      'x-github-media-type': 'github.v3; format=json',
      'access-control-expose-headers': 'ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, Deprecation, Sunset',
      'access-control-allow-origin': '*',
      'strict-transport-security': 'max-age=31536000; includeSubdomains; preload',
      'x-frame-options': 'deny',
      'x-content-type-options': 'nosniff',
      'x-xss-protection': '1; mode=block',
      'referrer-policy': 'origin-when-cross-origin, strict-origin-when-cross-origin',
      'content-security-policy': "default-src 'none'",
      vary: 'Accept-Encoding, Accept, X-Requested-With',
      'x-ratelimit-limit': '60',
      'x-ratelimit-remaining': '59',
      'x-ratelimit-reset': '1609830801',
      'x-ratelimit-used': '1',
      'content-length': '107',
      connection: 'close',
      'x-github-request-id': '07C0:70A3:5627175:C8346CC:5FF40381'
    },
    rawHeaders: [
      'server',
      'GitHub.com',
      'date',
      'Tue, 05 Jan 2021 06:13:21 GMT',
      'content-type',
      'application/json; charset=utf-8',
      'status',
      '404 Not Found',
      'x-github-media-type',
      'github.v3; format=json',
      'access-control-expose-headers',
      'ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, Deprecation, Sunset',
      'access-control-allow-origin',
      '*',
      'strict-transport-security',
      'max-age=31536000; includeSubdomains; preload',
      'x-frame-options',
      'deny',
      'x-content-type-options',
      'nosniff',
      'x-xss-protection',
      '1; mode=block',
      'referrer-policy',
      'origin-when-cross-origin, strict-origin-when-cross-origin',
      'content-security-policy',
      "default-src 'none'",
      'vary',
      'Accept-Encoding, Accept, X-Requested-With',
      'X-Ratelimit-Limit',
      '60',
      'X-Ratelimit-Remaining',
      '59',
      'X-Ratelimit-Reset',
      '1609830801',
      'X-Ratelimit-Used',
      '1',
      'Content-Length',
      '107',
      'Connection',
      'close',
      'X-GitHub-Request-Id',
      '07C0:70A3:5627175:C8346CC:5FF40381'
    ],
    trailers: {},
    rawTrailers: [],
    aborted: false,
    upgrade: false,
    url: '',
    method: null,
    statusCode: 404,
    statusMessage: 'Not Found',
    client: TLSSocket {
      _tlsOptions: [Object],
      _secureEstablished: true,
      _securePending: false,
      _newSessionPending: false,
      _controlReleased: true,
      _SNICallback: null,
      servername: 'api.github.com',
      alpnProtocol: false,
      authorized: true,
      authorizationError: null,
      encrypted: true,
      _events: [Object: null prototype],
      _eventsCount: 9,
      connecting: false,
      _hadError: false,
      _parent: null,
      _host: 'api.github.com',
      _readableState: [ReadableState],
      readable: true,
      _maxListeners: undefined,
      _writableState: [WritableState],
      writable: false,
      allowHalfOpen: false,
      _sockname: null,
      _pendingData: null,
      _pendingEncoding: '',
      server: undefined,
      _server: null,
      ssl: [TLSWrap],
      _requestCert: true,
      _rejectUnauthorized: true,
      parser: null,
      _httpMessage: [ClientRequest],
      [Symbol(res)]: [TLSWrap],
      [Symbol(asyncId)]: 3,
      [Symbol(kHandle)]: [TLSWrap],
      [Symbol(lastWriteQueueSize)]: 0,
      [Symbol(timeout)]: null,
      [Symbol(kBuffer)]: null,
      [Symbol(kBufferCb)]: null,
      [Symbol(kBufferGen)]: null,
      [Symbol(kBytesRead)]: 0,
      [Symbol(kBytesWritten)]: 0,
      [Symbol(connect-options)]: [Object]
    },
    _consuming: false,
    _dumped: false,
    req: ClientRequest {
      _events: [Object: null prototype],
      _eventsCount: 2,
      _maxListeners: undefined,
      outputData: [],
      outputSize: 0,
      writable: true,
      _last: true,
      chunkedEncoding: false,
      shouldKeepAlive: false,
      useChunkedEncodingByDefault: false,
      sendDate: false,
      _removedConnection: false,
      _removedContLen: false,
      _removedTE: false,
      _contentLength: 0,
      _hasBody: true,
      _trailer: '',
      finished: true,
      _headerSent: true,
      socket: [TLSSocket],
      connection: [TLSSocket],
      _header: 'GET /repos/DatStorm/crossfit-wod HTTP/1.1\r\n' +
        'User-Agent: github.com/ad-m/github-push-action\r\n' +
        'Host: api.github.com\r\n' +
        'Connection: close\r\n' +
        '\r\n',
      _onPendingData: [Function: noopPendingOutput],
      agent: [Agent],
      socketPath: undefined,
      method: 'GET',
      path: '/repos/DatStorm/crossfit-wod',
      _ended: true,
      res: [Circular],
      aborted: false,
      timeoutCb: null,
      upgradeOrConnect: false,
      parser: null,
      maxHeadersCount: null,
      [Symbol(kNeedDrain)]: false,
      [Symbol(isCorked)]: false,
      [Symbol(kOutHeaders)]: [Object: null prototype]
    }
  },
  body: '{"message":"Not Found","documentation_url":"https://docs.github.com/rest/reference/repos#get-a-repository"}'
}
Error: Invalid status code '404' for url 'https://api.github.com/repos/<USER>/<REPO>'
    at IncomingMessage.<anonymous> (/home/runner/work/_actions/ad-m/github-push-action/master/start.js:14:21)
    at IncomingMessage.emit (events.js:215:7)
    at endReadableNT (_stream_readable.js:1184:12)
    at processTicksAndRejections (internal/process/task_queues.js:80:21)

DatStorm avatar Jan 05 '21 06:01 DatStorm

Same issue on my projects. Is there any breaking change on Github api?

Lyken17 avatar Jan 05 '21 07:01 Lyken17

Switching to action@v2 can be a solution

https://stackoverflow.com/questions/57921401/push-to-origin-from-github-action/58393457#58393457

Lyken17 avatar Jan 05 '21 08:01 Lyken17

Yeah I have already made the switch to @v2 so it does not fix the problem for me.

DatStorm avatar Jan 05 '21 10:01 DatStorm

Try using the older version: ad-m/[email protected]

hadasarik avatar Jan 05 '21 11:01 hadasarik

Try using the older version: ad-m/[email protected]

did not work for me

sbalci avatar Jan 05 '21 14:01 sbalci

Already discussed in #68. Thank for you detailed report. I will take look on that in few hours. I believe authorization is perfomed in wrong way.

As workaround I suggest add branch: master or branch: main in workflow.

ad-m avatar Jan 05 '21 14:01 ad-m

with:
  branch: main

solves the problem as you suggested. Thank you for your time.

sbalci avatar Jan 05 '21 14:01 sbalci

I believe it was fixed in latest master code. Could somebody confirm?

ad-m avatar Jan 17 '21 16:01 ad-m

Just ran in to this issue. It still requires the branch declaration in the "with" segment to restore functionality.

qops1981 avatar Apr 13 '21 22:04 qops1981