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

v2.0.25 fails with 404 when using {repository} URL parameter set to ${{ github.repository }} #71

Closed
kd7lxl opened this issue Jan 25, 2021 · 8 comments · Fixed by #72
Closed

Comments

@kd7lxl
Copy link

kd7lxl commented Jan 25, 2021

We have a workflow that requests the list of files modified by a PR. Here's the code:

name: kube-score
on:
  # pull_request workflows run in the context of the fork, when applicable, and
  # thus does not have permission to comment on the PR. To support this, this
  # workflow only publishes an artifact and the comment will be posted by the
  # pr-comment workflow.
  # https://github.blog/2020-08-03-github-actions-improvements-for-fork-and-pull-request-workflows/#improvements-for-public-repository-forks
  pull_request:
    paths:
      - "**-version.txt"
jobs:
  kube-score:
    runs-on: ubuntu-latest
    timeout-minutes: 10
    steps:
      - uses: octokit/request-action@v2.x
        id: list_files
        with:
          route: GET /repos/:repository/pulls/:number/files
          repository: ${{ github.repository }}
          number: ${{ github.event.pull_request.number }}
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

This stopped working when v2.0.25 was released. The error is not found:

2021-01-25T21:49:32.3761923Z Download action repository 'octokit/request-action@v2.x'
2021-01-25T21:49:35.9635012Z ##[warning]Unexpected input(s) 'repository', 'number', valid inputs are ['route', 'mediaType']
2021-01-25T21:49:35.9691635Z ##[group]Run octokit/request-action@v2.x
2021-01-25T21:49:35.9692287Z with:
2021-01-25T21:49:35.9692842Z   route: GET /repos/:repository/pulls/:number/files
2021-01-25T21:49:35.9693621Z   repository: <redacted>
2021-01-25T21:49:35.9694284Z   number: 8631
2021-01-25T21:49:35.9694703Z   mediaType: {}
2021-01-25T21:49:35.9695128Z env:
2021-01-25T21:49:35.9696104Z   GITHUB_TOKEN: ***
2021-01-25T21:49:35.9696545Z ##[endgroup]
2021-01-25T21:49:36.3260397Z GET /repos/:repository/pulls/:number/files
2021-01-25T21:49:36.3261858Z > repository: <redacted>
2021-01-25T21:49:36.3262527Z > number: 8631
2021-01-25T21:49:36.3264255Z > mediaType: [object Object]
2021-01-25T21:49:36.4425840Z ##[error]Not Found

I looked at the diff and it's not obvious why it broke. I switched to - uses: octokit/request-action@v2.0.24 and it started working again.

@gr2m
Copy link
Contributor

gr2m commented Jan 25, 2021

Is this on a private repository? We do send requests using env.GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} in our tests, and they all passed. I'm not sure what broke either.

Can you please create a secret ACTIONS_STEP_DEBUG and set it to 1? That will enable debug logs

@DApple1
Copy link

DApple1 commented Jan 25, 2021

@gr2m I experienced a similar issue with a 'Not Found' error. For me, it looks like the repository parameter is not registering. I tested it out and if I have a setup like:

      - name: GET REPO
        uses: octokit/request-action@v2.x
        id: getRepo
        with:
          route: GET /repos/{repo}
          repo: ${{github.repository}}
          mediaType: '{"Accept": application/vnd.github.v3+json}'
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

I get the error, but if I replace the route to look like this without the repo parameter:

 route: GET /repos/${{github.repository}}

It works

@gr2m
Copy link
Contributor

gr2m commented Jan 26, 2021

It might be related to URL parameter encoding, see my comment here: #69 (comment)

Can you try setting owner / repo separately? The / character in github.repository is what is likely causing the problem here

@kd7lxl
Copy link
Author

kd7lxl commented Jan 26, 2021

Yes, that was it. Following 9736caa works. The workflow had not been updated with that usage change.

I'd recommend bumping more than just the patch version to indicate there was a breaking change.

@gr2m
Copy link
Contributor

gr2m commented Jan 26, 2021

I'd recommend bumping more than just the patch version to indicate there was a breaking change.

That change was not intentional, I'll try to fix/workaround it and push another version today

@gr2m gr2m changed the title v2.0.25 broke auth v2.0.25 fails with 404 when using {repository} URL parameter set to ${{ github.repository }} Jan 26, 2021
@gr2m gr2m pinned this issue Jan 26, 2021
@kd7lxl
Copy link
Author

kd7lxl commented Jan 26, 2021

Thanks for clarifying the title!

In case you're still curious, here's the debug log: https://gist.github.com/kd7lxl/29ad1c2144692e49cc7067e2af634a87

@gr2m
Copy link
Contributor

gr2m commented Jan 26, 2021

Thanks! You can see the incorrect URL encoding of the repository owner/name in https://gist.github.com/kd7lxl/29ad1c2144692e49cc7067e2af634a87#file-action-log-L102, that's why you get a 404

@gr2m gr2m closed this as completed in #72 Jan 26, 2021
@gr2m
Copy link
Contributor

gr2m commented Jan 26, 2021

🎉 This issue has been resolved in version 2.0.26 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

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

Successfully merging a pull request may close this issue.

3 participants