octokit / request-action

A GitHub Action to send arbitrary requests to GitHub's REST API
https://github.com/marketplace/actions/GitHub-API-Request
MIT License
368 stars 48 forks source link

Cannot read property 'map' of undefined #175

Closed oeed closed 1 year ago

oeed commented 2 years ago

I'm trying to download the contents of a file from another repo and I'm getting a rather unhelpful error. Nothing I've tried seems to help.

Action:

- name: Download Desktop Client Types
  uses: octokit/request-action@v2.x
  id: get_desktop_client
  with:
    route: GET /repos/OWNER/REPO/contents/src/types/api.d.ts
    mediaType: application/vnd.github.raw
  env:
    GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Run octokit/request-action@v2.x
GET /repos/OWNER/REPORT/contents/src/types/api.d.ts
> mediaType: application/vnd.github.raw

(node:15[9](https://github.com/SpalkLtd/content-hub/runs/7891226272?check_suite_focus=true#step:3:10)1) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
Error: Cannot read property 'map' of undefined
timrogers commented 2 years ago

It's not clear to me how map is getting called, looking at the code for octokit/request-action.

Can you try following the instructions here to enable debug logging? I'm wondering if that might help us to get more context.

oeed commented 2 years ago

I ended up using action-script which led me to discover that the GitHub token I was using didn't have access to the repo (got a 404), so it's likely something handling that incorrectly.

timrogers commented 2 years ago

I was able to reproduce the issue with a minimal workflow file like this:

name: Download file without required permissions
on: workflow_dispatch

jobs:
  download_file:
    runs-on: ubuntu-latest
    steps:
      - uses: octokit/request-action@v2.x
        id: download_file
        with:
          route: GET /repos/{owner}/{repo}/contents/README.md
          mediaType: application/vnd.github.raw
          owner: github
          repo: github
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

I'll try to figure out what's going on.

timrogers commented 2 years ago

I've got a fix for this now in #176! Thanks for reporting the issue.

timrogers commented 2 years ago

It seems that, in fact, there is a way to do this - see https://github.com/octokit/request-action/pull/184.

octokitbot commented 1 year ago

:tada: This issue has been resolved in version 2.1.7 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket: