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

Fails with "Not Found" error

Open nunnatsa opened this issue 4 years ago • 16 comments

Was trying to use this action in my workflow. It keep failing with "Not Found" error:

https://github.com/kubevirt/hyperconverged-cluster-operator/pull/1176/checks?check_run_id=2076631480

Error: Error setting status:
Not Found
Request object:
{
  "context": "sanity-test",
  "description": "Passed",
  "state": "success",
  "owner": "kubevirt",
  "repo": "hyperconverged-cluster-operator",
  "sha": "77bf072c596a1e6cbc7a76e90d33c1f795840c6e",
  "target_url": ""
}

It is not clear to me what went wrong and how to fix it.

nunnatsa avatar Mar 10 '21 13:03 nunnatsa

Hi, sorry this isn't a very clear error message. I will look into what is not found, get back to you and also update the error message.

Sibz avatar Mar 10 '21 22:03 Sibz

It seems the error message Not Found is returned from the github request, thus it must be referring to the SHA, of course it exists, however the token used must not have access to it. I see this is running on a forked repository, so I might guess the token has access the the original repository but not the forked one.

Not sure on the best way around this, as using a token for the forked repository will cause the request to fail once merged, and in it's current state it should complete once merged.

Only thing that comes to mind is to merge into a branch on the origin repository, then PR from that local branch to confirm the status is updated as expected.

Sibz avatar Mar 10 '21 22:03 Sibz

@nunnatsa When you get a chance, let me know how you got on.

Sibz avatar Mar 12 '21 04:03 Sibz

I think this issue is caused by the new GitHub security policy to give only READ access tokens to PRs from forks.

This means that any status checks won't work against external PRs which is a bit unfortunate.

The easiest workaround is to use pull_request_target instead of pull_request, the author just needs to be aware that it's not safe to build or run the PR code in that case.

I think github status update should be safe in this context.

In my case, my action is using pull_request_review_comment which has the same restrictions but no alternative. I think the only thing I could do is follow the advice to run this action via workflow_run event after uploading status details from my pull_request_review_comment action.

(This is my opinion after reading https://securitylab.github.com/research/github-actions-preventing-pwn-requests/ a few times but it might be usefult o updat the README.md if you come to the same conclusion)

melink14 avatar May 04 '21 02:05 melink14

I get exactly the same error on push, while on pull request it works well Error: Error setting status: Not Found Request object: { "context": "Test report", "description": "", "state": "success", "owner": "XXX", "repo": "XXX-automation", "sha": "", "target_url": "https://XXX.github.io/XXX-automation/94" } image

olgadayneko avatar Jun 23 '21 07:06 olgadayneko

@olgadayneko do you have links to actual logs and workflow?

From what you pasted, sha is the empty string so it seems like the workflow may be grabbing a sha which exists during pull requests events but not during push events.

melink14 avatar Jun 23 '21 07:06 melink14

@olgadayneko do you have links to actual logs and workflow?

From what you pasted, sha is the empty string so it seems like the workflow may be grabbing a sha which exists during pull requests events but not during push events.

Which part of the logs do you need? Unfortunately it's a work repo and I cannot share full logs due to security rules.

Here is the workflow

name: Test Execution INT

# Controls when the action will run.
on:
  workflow_dispatch:
  pull_request:
    branches:
      - development
      - master
  push:
    branches:
      - development
      - master

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
  # This workflow contains a single job called "build"
  run-regression-tests:
    # The type of runner that the job will run on
    runs-on: ubuntu-latest

    # Steps represent a sequence of tasks that will be executed as part of the job
    steps:
      # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
      - uses: actions/checkout@v2
        with:
          fetch-depth: 1

      - name: Installing java
        uses: actions/setup-java@v1
        with:
          java-version: 11.0.4
          java-package: jdk
          architecture: x64

      - name: Load maven cache
        uses: actions/cache@v2
        with:
          path: ~/.m2/repository
          key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
          restore-keys: |
            ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
      - name: Retrieving allure reports
        uses: actions/checkout@v2
        with:
          fetch-depth: 1
          ref: 'reportsAllure'
          path: './reports/allure'

      - name: Start selenoid
        if: success()
        uses: Xotabu4/selenoid-github-action@v1

      - name: Create env file
        run: |
          ls -a
          touch .env
         xxx
          cat .env
      
      - name: Run tests
        id: tests
        run: mvn test -X -D"xxx_ENV"="INT" -D"PIPELINE_RUN"="true"

      - name: Generate allure reports
        run: mvn allure:report

      - name: Get Allure history
        uses: actions/checkout@v2
        if: always()
        continue-on-error: true
        with:
          ref: reportsAllure
          path: reportsAllure

      - name: Allure Report action
        uses: simple-elf/allure-report-action@master
        if: always()
        id: allure-report
        with:
          gh_pages: reportsAllure
          allure_results: target/allure-results
          allure_history: history
          allure_report: target/allure-report
          keep_reports: 25

      - name: Publish report to Github Pages
        if: always()
        uses: peaceiris/actions-gh-pages@v3
        with:
          PERSONAL_TOKEN: ${{secrets.GITHUB_TOKEN}}
          PUBLISH_BRANCH: reportsAllure
          PUBLISH_DIR: history

      - name: Print the link to the report
        if: always()
        uses: Sibz/github-status-action@v1
        with:
          authToken: ${{secrets.GITHUB_TOKEN}}
          context: 'Test report'
          state: 'success'
          sha: ${{ github.event.pull_request.head.sha }}
          target_url: https://xxx.github.io/xxx-automation/${{ github.run_number }}

olgadayneko avatar Jun 23 '21 08:06 olgadayneko

The workflow is actually enough since it confirms the problem is how you're passing the sha.

sha: ${{ github.event.pull_request.head.sha }}

means you'll only have a sha value during pull_request events. You'll probably want to add a conditional sha based on which event triggered the workflow.

melink14 avatar Jun 23 '21 08:06 melink14

The example in the README actually solves for this exact case so I would follow that and chagne your sha argument to: sha: ${{github.event.pull_request.head.sha || github.sha}}

melink14 avatar Jun 23 '21 08:06 melink14

Got this "Not Found" error as well, but it doesn't seem like an issue with sha property.

Error: Error setting status:
Not Found
Request object:
{
  "context": "E2E tests",
  "description": "Cypress ran the tests",
  "state": "failure",
  "owner": "gatezh",
  "repo": "bankand.me",
  "sha": "6bd3f39b8cf644ce982504183028e48ce5369edc",
  "target_url": ""
}

I was following the example of setting up cypress test in a separate repo:

Can somebody please advice what needs to be changed?

gatezh avatar Aug 08 '21 21:08 gatezh

@gatezh Sorry about the delay in responding.

Is the PR that it is failing on originating in the same repository or a forked repository?

Sibz avatar Aug 11 '21 07:08 Sibz

Hey @Sibz, It is failing on a PR in a separate repo, not a fork.

gatezh avatar Aug 14 '21 22:08 gatezh

Any chance someone can help me with this issue, please?

gatezh avatar Aug 22 '21 15:08 gatezh

@gatezh Sorry again for the delay, I've been busy, I will look into this in a bit more detail asap. Thank you for your patience, I hope to get to the bottom of this for you.

Sibz avatar Aug 22 '21 20:08 Sibz

I'm very sorry for the continued lack of response to this issue, I simply have too much on my plate at the moment. I would welcome any collaboration to address this issue.

Sibz avatar Sep 26 '21 01:09 Sibz

Hi

I am not able to see any link to access and when i clicke generated link, it shows 404 error

Run Sibz/github-status-action@v1 with: authToken: *** context: Test report state: success sha: 6fc3674b97b6be6562XXXXX target_url: https://XXX.github.io/XXXX/41 owner: XXX repository: xxxx/xxxxxx

where is my mistake ?

neerajkumarlad avatar May 20 '22 06:05 neerajkumarlad