-
-
Notifications
You must be signed in to change notification settings - Fork 520
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
PullRequestPostAnalysisTask fail with GraphQLException: Not Found #100
Comments
Your Github API URL (sonar.pullrequest.github.endpoint) doesn't look right: it shouldn't have the version number in it. Could you try removing the |
I have tried with and without v3 on the end of the API URL. With v3 I get the same exception listed above. Without v3 I get the following error:
|
Github.com's API does not contain version numbers in the path for REST endpoints (e.g. api.github.com/endpoint), but Github Enterprise does (e.g. github.company.net/api/v3/endpoint), however neither platforms use version numbers in the Graphql endpoint (e.g. api.github.com/graphql and github.company.net/api/graphql). The plugin was not previously differentiating between the two possible platforms based on the configured base URL, so was using the wrong REST endpoint when performing the authentication request, or was targeting the wrong graphql url if the user configured the URL to end with `v3`. Checking if the configured URL ends with `api` indicates the URL is Github enterprise rather than Github.com, so now had `v3` appended to it for the authentication request.
Is there any chance you could try building and running the plugin from the issue/100 branch? It contains a fix to detect when the URL is a Github Enterprise one and therefore uses a corrected target URL for retrieving the authentication token. |
I will build and test it tomorrow. |
Tested it on our GHE instance, and that fix seems to have worked. I'll get a PR up in a bit to document GHE setup. If I can suggest a change, I think it would be nice to require the url to have v3, and remove it for the graphql api calls if its there. That way the existing documentation located at https://docs.sonarqube.org/latest/instance-administration/github-application/ could still be followed. |
The same issue can be reproduced in #58 and the fix should likely get merged there as well.
|
I'll merge my proposed fix into master before #58 gets merged, so the SQ 8.1 release will automatically include this fix. |
Github.com's API does not contain version numbers in the path for REST endpoints (e.g. api.github.com/endpoint), but Github Enterprise does (e.g. github.company.net/api/v3/endpoint), however neither platforms use version numbers in the Graphql endpoint (e.g. api.github.com/graphql and github.company.net/api/graphql). The plugin was not previously differentiating between the two possible platforms based on the configured base URL, so was using the wrong REST endpoint when performing the authentication request, or was targeting the wrong graphql url if the user configured the URL to end with `v3`. Checking if the configured URL ends with `api` indicates the URL is Github enterprise rather than Github.com, so now had `v3` appended to it for the authentication request.
Hello @mc1arke, But if the URL ends with /v3 then it does not work, because then POST /api/v3/graphql URL is used in SonarQube. Once I removed /v3 from URL it started work. Thanks, |
…ise hosts Github.com's API does not contain version numbers in the path for REST endpoints (e.g. api.github.com/endpoint), but Github Enterprise does (e.g. github.company.net/api/v3/endpoint), however neither platforms use version numbers in the Graphql endpoint (e.g. api.github.com/graphql and github.company.net/api/graphql). The plugin was not previously differentiating between the two possible platforms based on the configured base URL, so was using the wrong REST endpoint when performing the authentication request, or was targeting the wrong graphql url if the user configured the URL to end with `v3`. Checking if the configured URL ends with `api` indicates the URL is Github enterprise rather than Github.com, so now had `v3` appended to it for the authentication request. This change will also support GitHub Enterprise URLs with or without a trailing `v3/` in the endpoint. # Please enter the commit message for your changes. Lines starting # with '#' will be kept; you may remove them yourself if you want to. # An empty message aborts the commit. # # Author: Michael Clarke <[email protected]> # Date: Wed Feb 26 21:58:44 2020 +0000 # # On branch issue/100 # Your branch and 'origin/issue/100' have diverged, # and have 1 and 1 different commits each, respectively. # # Changes to be committed: # modified: src/main/java/com/github/mc1arke/sonarqube/plugin/CommunityBranchPlugin.java # modified: src/main/java/com/github/mc1arke/sonarqube/plugin/ce/pullrequest/github/v3/RestApplicationAuthenticationProvider.java # modified: src/main/java/com/github/mc1arke/sonarqube/plugin/ce/pullrequest/github/v4/GraphqlCheckRunProvider.java # modified: src/test/java/com/github/mc1arke/sonarqube/plugin/ce/pullrequest/github/v3/RestApplicationAuthenticationProviderTest.java # modified: src/test/java/com/github/mc1arke/sonarqube/plugin/ce/pullrequest/github/v4/GraphqlCheckRunProviderTest.java #
…ise hosts Github.com's API does not contain version numbers in the path for REST endpoints (e.g. api.github.com/endpoint), but Github Enterprise does (e.g. github.company.net/api/v3/endpoint), however neither platforms use version numbers in the Graphql endpoint (e.g. api.github.com/graphql and github.company.net/api/graphql). The plugin was not previously differentiating between the two possible platforms based on the configured base URL, so was using the wrong REST endpoint when performing the authentication request, or was targeting the wrong graphql url if the user configured the URL to end with `v3`. Checking if the configured URL ends with `api` indicates the URL is Github enterprise rather than Github.com, so now had `v3` appended to it for the authentication request. This change will also support GitHub Enterprise URLs with or without a trailing `v3/` in the endpoint.
…ise hosts Github.com's API does not contain version numbers in the path for REST endpoints (e.g. api.github.com/endpoint), but Github Enterprise does (e.g. github.company.net/api/v3/endpoint), however neither platforms use version numbers in the Graphql endpoint (e.g. api.github.com/graphql and github.company.net/api/graphql). The plugin was not previously differentiating between the two possible platforms based on the configured base URL, so was using the wrong REST endpoint when performing the authentication request, or was targeting the wrong graphql url if the user configured the URL to end with `v3`. Checking if the configured URL ends with `api` indicates the URL is Github enterprise rather than Github.com, so now had `v3` appended to it for the authentication request. This change will also support GitHub Enterprise URLs with or without a trailing `v3/` in the endpoint.
Github.com's API does not contain version numbers in the path for REST endpoints (e.g. api.github.com/endpoint), but Github Enterprise does (e.g. github.company.net/api/v3/endpoint), however neither platforms use version numbers in the Graphql endpoint (e.g. api.github.com/graphql and github.company.net/api/graphql). The plugin was not previously differentiating between the two possible platforms based on the configured base URL, so was using the wrong REST endpoint when performing the authentication request, or was targeting the wrong graphql url if the user configured the URL to end with `v3`. Checking if the configured URL ends with `api` indicates the URL is Github enterprise rather than Github.com, so now had `v3` appended to it for the authentication request. This change will also support GitHub Enterprise URLs with or without a trailing `v3/` in the endpoint.
Hello ! Nice work on this plugin :) Thank you |
Describe the bug
PullRequestPostAnalysisTask fail with GraphQLException: Not Found . This occur tying to run the pull request build and I don't see the PR decorator in Github repository. Refer exception stack trace at the bottom of the report.
To Reproduce
Steps to reproduce the behavior:
I'm running the sonar analysis through Jenkins and following is the
mvn
command use to run the analysis.mvn verify -Dsonar.pullrequest.github.repository=OrgName/RepoName -Dsonar.pullrequest.branch=origin/PR-53 -Dsonar.pullrequest.key=53 sonar:sonar -P check-snapshots,sonar -Dsonar.host.url=http://sonarqube792.com/ -Dsonar.login=****
I create the Github App following the instructions in the plugin README
Expected behavior
Should display the PR decorator in Github.
Screenshots
Attached sonar PR configuration screenshot -
Software Versions
Additional context
Exception Stack Trace
The text was updated successfully, but these errors were encountered: