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

Auth is not working when GitHub App and GH EE URL configured together #364

Closed
oldboys92 opened this issue Sep 11, 2024 · 5 comments · Fixed by github/evergreen#256
Closed
Assignees
Labels
bug Something isn't working keep

Comments

@oldboys92
Copy link

Describe the bug

After setting GH_ENTERPRISE_URL and corresponding GitHub APP parameters the issue-metrics action still tries to use GitHub public to login.

After checking the implementation code it seems that the combination of GH EE and GitHub APP is not supported, but the documentation is not clear about this.

To Reproduce

  1. Setup GH_ENTERPRISE_URL
  2. Setup GH_APP_ID, GH_APP_INSTALLATION_ID and GH_APP_PRIVATE_KEY
  3. Start your workflow
  4. see the error:
2024-09-11T19:03:22.0564009Z ##[group]Run github/issue-metrics@v3
2024-09-11T19:03:22.0564483Z env:
2024-09-11T19:03:22.0564839Z   last_month: 2024-08-01..2024-08-31
2024-09-11T19:03:22.0565410Z   GH_ENTERPRISE_URL: https://git.example.com/api/v3/
2024-09-11T19:03:22.0566025Z   GH_APP_ID: ***
2024-09-11T19:03:22.0566520Z   GH_APP_INSTALLATION_ID: ***
2024-09-11T19:03:22.0577928Z   GH_APP_PRIVATE_KEY: ***
2024-09-11T19:03:22.0578647Z   SEARCH_QUERY: repo:owner/repo-name is:issue created:2024-08-01..2024-08-31 -reason:"not planned"
2024-09-11T19:03:22.0579394Z ##[endgroup]
2024-09-11T19:03:22.0776388Z ##[command]/usr/local/bin/docker run --name ghcriogithubissue_metricsv3_a7f194 --label 465bd8 --workdir /github/workspace --rm -e "last_month" -e "GH_ENTERPRISE_URL" -e "GH_APP_ID" -e "GH_APP_INSTALLATION_ID" -e "GH_APP_PRIVATE_KEY" -e "SEARCH_QUERY" -e "HOME" -e "GITHUB_JOB" -e "GITHUB_REF" -e "GITHUB_SHA" -e "GITHUB_REPOSITORY" -e "GITHUB_REPOSITORY_OWNER" -e "GITHUB_REPOSITORY_OWNER_ID" -e "GITHUB_RUN_ID" -e "GITHUB_RUN_NUMBER" -e "GITHUB_RETENTION_DAYS" -e "GITHUB_RUN_ATTEMPT" -e "GITHUB_REPOSITORY_ID" -e "GITHUB_ACTOR_ID" -e "GITHUB_ACTOR" -e "GITHUB_TRIGGERING_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_WORKFLOW_REF" -e "GITHUB_WORKFLOW_SHA" -e "GITHUB_WORKSPACE" -e "GITHUB_EVENT_PATH" -e "GITHUB_PATH" -e "GITHUB_ENV" -e "GITHUB_STEP_SUMMARY" -e "GITHUB_STATE" -e "GITHUB_OUTPUT" -e "GITHUB_ACTION" -e "GITHUB_ACTION_REPOSITORY" -e "GITHUB_ACTION_REF" -e "RUNNER_OS" -e "RUNNER_ARCH" -e "RUNNER_NAME" -e "RUNNER_ENVIRONMENT" -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 "/runner/_work/_temp/_github_home":"/github/home" -v "/runner/_work/_temp/_github_workflow":"/github/workflow" -v "/runner/_work/_temp/_runner_file_commands":"/github/file_commands" -v "/runner/_work/test_issue_bot/test_issue_bot":"/github/workspace" ghcr.io/github/issue_metrics:v3
2024-09-11T19:03:28.9219554Z Starting issue-metrics search...
2024-09-11T19:03:29.1252999Z Request failed: 401 Client Error: Unauthorized for url: https://api.github.com/app/installations/***/access_tokens
2024-09-11T19:03:29.3067052Z Traceback (most recent call last):
2024-09-11T19:03:29.3069824Z   File "/action/workspace/issue_metrics.py", line 433, in <module>
2024-09-11T19:03:29.3071230Z     main()
2024-09-11T19:03:29.3072261Z   File "/action/workspace/issue_metrics.py", line 320, in main
2024-09-11T19:03:29.3073579Z     github_connection = auth_to_github(
2024-09-11T19:03:29.3074930Z                         ^^^^^^^^^^^^^^^
2024-09-11T19:03:29.3076020Z   File "/action/workspace/auth.py", line 26, in auth_to_github
2024-09-11T19:03:29.3077183Z     gh.login_as_app_installation(
2024-09-11T19:03:29.3079084Z   File "/usr/local/lib/python3.12/site-packages/github3/github.py", line 1527, in login_as_app_installation
2024-09-11T19:03:29.3080844Z     json = self._json(response, 201)
2024-09-11T19:03:29.3082275Z            ^^^^^^^^^^^^^^^^^^^^^^^^^
2024-09-11T19:03:29.3084336Z   File "/usr/local/lib/python3.12/site-packages/github3/models.py", line 161, in _json
2024-09-11T19:03:29.3086359Z     raise exceptions.error_for(response)
2024-09-11T19:03:29.3088287Z github3.exceptions.AuthenticationFailed: 401 A JSON web token could not be decoded
2024-09-11T19:03:30.0039306Z Post job cleanup.

Expected behavior

Setting GH_ENTERPRISE_URL should trigger the correct usage of the GitHub EE authentication endpoint.

Screenshots

No response

Additional context

No response

@oldboys92 oldboys92 added the bug Something isn't working label Sep 11, 2024
@zkoppert
Copy link
Member

Yes, that is correct that the code doesn't currently accommodate that option but I don't think there is anything preventing us from a technical implementation for that. So we would be open to a pull request on this or once a maintainer found the time we could add this configuration.

@zkoppert zkoppert added the keep label Sep 20, 2024
@oldboys92
Copy link
Author

I will prepare a PR then, but it will take sometime (longer vacation next month).

@zkoppert
Copy link
Member

Thank you!

@jmeridth jmeridth self-assigned this Sep 28, 2024
@jmeridth
Copy link
Member

@oldboys92 you still want to get a PR out for this? Or I can take a look at it. I don't want to block you. Thank you for filing the issue.

@oldboys92
Copy link
Author

many thx for fixing it and sorry for the late reply, I had a long vacation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working keep
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants