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

Some API access fails when using secrets.GITHUB_TOKEN. #466

Open
417-72KI opened this issue Sep 22, 2021 · 12 comments
Open

Some API access fails when using secrets.GITHUB_TOKEN. #466

417-72KI opened this issue Sep 22, 2021 · 12 comments

Comments

@417-72KI
Copy link
Member

Request failed [403]: https://api.github.com/user
Response: {
  "message": "Resource not accessible by integration",
  "documentation_url": "https://docs.github.com/rest/reference/users#get-the-authenticated-user"
}
Request failed [403]: https://api.github.com/repos/danger/swift/pulls/465/comments
Response: {
  "message": "Resource not accessible by integration",
  "documentation_url": "https://docs.github.com/rest"
}
Request failed [403]: https://api.github.com/user
Response: {
  "message": "Resource not accessible by integration",
  "documentation_url": "https://docs.github.com/rest/reference/users#get-the-authenticated-user"
}
Request failed [403]: https://api.github.com/repos/danger/swift/issues/465/comments
Response: {
  "message": "Resource not accessible by integration",
  "documentation_url": "https://docs.github.com/rest/reference/issues#create-an-issue-comment"
}
Feedback: undefined
Could not add a commit status, the GitHub token for Danger does not have access rights.
If the build fails, then danger will use a failing exit code.
@f-meloni
Copy link
Member

Hey!
Are you setting the GITHUB_TOKEN like this in your action?

GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

?

Becuase that should avoid the call to https://api.github.com/user

@f-meloni
Copy link
Member

f-meloni commented Sep 26, 2021

Actually now danger-js has this code

https://github.com/danger/danger-js/blob/fe5f080b4a267012dd80a9d589faee3bd278dc18/source/platforms/github/GitHubAPI.ts#L139

so shouldn't try to get the user if there is GITHUB_WORKFLOW and use the default one 🤔

@417-72KI
Copy link
Member Author

This is an another PR on this repo.
https://github.com/danger/swift/pull/467/checks?check_run_id=3713455793#step:9:31

As you know, Dangerfile.swift in here doesn't call /user.
However, the error has been occurring 🥺.

I think this is a mystery🤔.

@f-meloni
Copy link
Member

May it be that given it is from a fork it doesn't get the env variables?

@f-meloni
Copy link
Member

I opened #468 to try see if it has the same issue or not

@f-meloni
Copy link
Member

In that PR I've seen the error only on Linux, then I've opened #469, and I saw that even if it had that issue, it posted on the PR anyway

@Samasaur1
Copy link

I am also seeing this error. I'm running the GitHub Action, and it's not running from a fork. I get issue comments and status checks fine, but I do not get inline fails. The weirdest thing about it is that I could have sworn that I did get some inlined fails, but now it isn't working. Here is my workflow file:

name: danger

# Controls when the action will run. This action runs Danger, so run on PRs only
on: pull_request

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
  test:
    name: Run Danger
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: danger/swift@3.12.3
        with:
          args: --use-github-checks --verbose
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

and here is the output:

2022-06-04T19:02:10.4394334Z ##[group]Run danger/swift@3.12.3
2022-06-04T19:02:10.4394649Z with:
2022-06-04T19:02:10.4394936Z   args: --use-github-checks --verbose
2022-06-04T19:02:10.4395212Z env:
2022-06-04T19:02:10.4395817Z   GITHUB_TOKEN: ***
2022-06-04T19:02:10.4396089Z ##[endgroup]
2022-06-04T19:02:10.4600872Z ##[command]/usr/bin/docker run --name f1554334afe00e5814c2b9323b09709a112e5_cf05f6 --label 6f1554 --workdir /github/workspace --rm -e GITHUB_TOKEN -e INPUT_ARGS -e HOME -e GITHUB_JOB -e GITHUB_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_REPOSITORY_OWNER -e GITHUB_RUN_ID -e GITHUB_RUN_NUMBER -e GITHUB_RETENTION_DAYS -e GITHUB_RUN_ATTEMPT -e GITHUB_ACTOR -e GITHUB_WORKFLOW -e GITHUB_HEAD_REF -e GITHUB_BASE_REF -e GITHUB_EVENT_NAME -e GITHUB_SERVER_URL -e GITHUB_API_URL -e GITHUB_GRAPHQL_URL -e GITHUB_REF_NAME -e GITHUB_REF_PROTECTED -e GITHUB_REF_TYPE -e GITHUB_WORKSPACE -e GITHUB_ACTION -e GITHUB_EVENT_PATH -e GITHUB_ACTION_REPOSITORY -e GITHUB_ACTION_REF -e GITHUB_PATH -e GITHUB_ENV -e GITHUB_STEP_SUMMARY -e RUNNER_OS -e RUNNER_ARCH -e RUNNER_NAME -e RUNNER_TOOL_CACHE -e RUNNER_TEMP -e RUNNER_WORKSPACE -e ACTIONS_RUNTIME_URL -e ACTIONS_RUNTIME_TOKEN -e ACTIONS_CACHE_URL -e GITHUB_ACTIONS=true -e CI=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/_temp/_runner_file_commands":"/github/file_commands" -v "/home/runner/work/DiceKit/DiceKit":"/github/workspace" 6f1554:334afe00e5814c2b9323b09709a112e5 --use-github-checks --verbose
2022-06-04T19:02:15.2912726Z Ran with: /tmp/_tmp_dangerfile.swift runner /usr/lib/node_modules/danger/distribution/commands/danger-ci.js --process danger-swift --passURLForDSL --use-github-checks --verbose /tmp/danger-dsl.json /tmp/danger-response.json
2022-06-04T19:02:15.2913822Z �[0;0mDecoding the DSL into Swift types
2022-06-04T19:02:15.2914288Z �[0;0mSetting up to dump results
2022-06-04T19:02:15.2914690Z �[0;0mSending results back to Danger
2022-06-04T19:02:15.2915145Z �[0;0mSending results back to Danger
2022-06-04T19:02:15.2915586Z �[0;0mSending results back to Danger
2022-06-04T19:02:15.2916053Z �[0;0mSending results back to Danger
2022-06-04T19:02:15.2916437Z �[0;0mSending results back to Danger
2022-06-04T19:02:15.2916860Z �[0;0mSending results back to Danger
2022-06-04T19:02:15.2917285Z �[0;0mSending results back to Danger
2022-06-04T19:02:15.2917734Z �[0;0mSending results back to Danger
2022-06-04T19:02:15.2918121Z �[0;0mSending results back to Danger
2022-06-04T19:02:15.2918552Z �[0;0mSending results back to Danger
2022-06-04T19:02:15.2918968Z �[0;0mSending results back to Danger
2022-06-04T19:02:15.2919295Z �[0;0m
2022-06-04T19:02:15.3157214Z 
2022-06-04T19:02:15.3157224Z 
2022-06-04T19:02:15.3163795Z Launching Danger Swift runner (v3.12.3)
2022-06-04T19:02:15.3164499Z �[0;0mGot URL for JSON: /tmp/danger-dsl.json
2022-06-04T19:02:15.3164994Z �[0;0mCreated a temporary file for the Dangerfile DSL at: /tmp/danger-dsl.json
2022-06-04T19:02:15.3167056Z �[0;0mRunning Dangerfile at: Dangerfile.swift
2022-06-04T19:02:15.3169812Z �[0;0mPreparing to compile
2022-06-04T19:02:15.3173003Z �[0;0mRunning: /usr/bin/swift --driver-mode=swift -L /usr/local/lib/danger -I /usr/local/lib/danger -lDanger /tmp/_tmp_dangerfile.swift runner /usr/lib/node_modules/danger/distribution/commands/danger-ci.js --process danger-swift --passURLForDSL --use-github-checks --verbose /tmp/danger-dsl.json /tmp/danger-response.json
2022-06-04T19:02:15.3175379Z �[0;0mCompleted evaluation
2022-06-04T19:02:15.3175996Z �[0;0mSaving and storing the results at /tmp/danger-response.json
2022-06-04T19:02:15.3176539Z �[0;0m
2022-06-04T19:02:15.3274372Z Failing the build, there are 5 fails.
2022-06-04T19:02:15.6150716Z Request failed [403]: https://api.github.com/user
2022-06-04T19:02:15.6159268Z Response: {
2022-06-04T19:02:15.6159774Z   "message": "Resource not accessible by integration",
2022-06-04T19:02:15.6160693Z   "documentation_url": "https://docs.github.com/rest/reference/users#get-the-authenticated-user"
2022-06-04T19:02:15.6161098Z }
2022-06-04T19:02:16.6188193Z Request failed [403]: https://api.github.com/user
2022-06-04T19:02:16.6194093Z Response: {
2022-06-04T19:02:16.6194446Z   "message": "Resource not accessible by integration",
2022-06-04T19:02:16.6195260Z   "documentation_url": "https://docs.github.com/rest/reference/users#get-the-authenticated-user"
2022-06-04T19:02:16.6195859Z }
2022-06-04T19:02:17.8209678Z Feedback: https://github.com/Samasaur1/DiceKit/pull/101#issuecomment-1146669500
2022-06-04T19:02:18.3548973Z Danger: ⅹ Failing the build, there are 5 fails.
2022-06-04T19:02:18.3549253Z ## Failures
               -- various Danger-reported fails, messages, etc. --
2022-06-04T19:02:18.3608323Z 
2022-06-04T19:02:18.4168679Z Launching Danger Swift ci (v3.12.3)
2022-06-04T19:02:18.4169291Z �[0;0mFinding out where the danger executable is
2022-06-04T19:02:18.4169952Z �[0;0mRunning: /usr/bin/danger ci --process danger-swift --passURLForDSL --use-github-checks --verbose 
2022-06-04T19:02:18.5618807Z �[0;0m

@stodirascu
Copy link

stodirascu commented Nov 11, 2022

I think I know what's going on. @f-meloni pointed me to the root cause. As you can see here, before checking if it's a workflow, it attempts to get the user anyway. This PR fixes it.

@JubrilO
Copy link

JubrilO commented Nov 11, 2022

@f-meloni I have run into this issue as well. Here's my workflow file below

name: Primary
on:
  pull_request:
    types: [opened, synchronize, reopened]
    
  workflow_dispatch:

jobs:
  CodeQuality:
    runs-on: ubuntu-latest
    name: Code quality Checks
    
    steps:
     - uses: actions/checkout@v1
     - name: Danger
       uses: docker://ghcr.io/danger/danger-swift-with-swiftlint:3.14.2
       with:
            args: --failOnErrors --no-publish-check
       env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Here's the output

Failing the build, there are 33 fails.
Request failed [403]: https://api.github.com/user
Response: {
  "message": "Resource not accessible by integration",
  "documentation_url": "https://docs.github.com/rest/reference/users#get-the-authenticated-user"
}
Request failed [422]: https://api.github.com/repos/s/sdk_ios/pulls/31/reviews
Response: {
  "message": "Unprocessable Entity"
"errors": [
    "Pull request review thread position is invalid and Pull request review thread diff hunk can't be blank"
  ],
  "documentation_url": "https://docs.github.com/rest/reference/pulls#create-a-review-for-a-pull-request"
}
Feedback: undefined

@JubrilO
Copy link

JubrilO commented Nov 14, 2022

@f-meloni Please can you create a new release of the Danger with swift lint docker image. The issue was fixed in this PR.

@stodirascu
Copy link

@JubrilO, that release is in another repo and it was handled by @orta. Release is here.

Maybe @417-72KI can check and close this.

@f-meloni
Copy link
Member

@f-meloni Please can you create a new release of the Danger with swift lint docker image. The issue was fixed in this PR.

I've just done it, it is building now, you should get the new docker image with the updated danger-js soon (if the build is successful)

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

5 participants