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

Addition of listCodeownersErrors() #1597

Closed
michael-s-grant opened this issue Jan 10, 2023 · 11 comments · Fixed by #1610
Closed

Addition of listCodeownersErrors() #1597

michael-s-grant opened this issue Jan 10, 2023 · 11 comments · Fixed by #1610

Comments

@michael-s-grant
Copy link
Contributor

I would like to contribute a method offering access to the GitHub API call /repos/{owner}/{repo}/codeowners/errors.

@michael-s-grant
Copy link
Contributor Author

The test repository does not have a .github/CODEOWNERS file to test against. For unit testing I could therefore either add one, or manually edit the Wiremock data. What's your preference?

@bitwiseman
Copy link
Member

Add the file, that seems fine.

@michael-s-grant
Copy link
Contributor Author

I just tried, and got 403 Forbidden. Could you either give me permission, or yourself add the file containing the following single line?
@nonexistent-user # Deliberate error to test response to repo.listCodeownersErrors()

@bitwiseman
Copy link
Member

I've invited you to the hub4j-test-org.

bitwiseman added a commit that referenced this issue Jan 27, 2023
…istCodeownersErrors

Issue #1597: Add deliberately broken CODEOWNERS file
@robinvandenbogaard
Copy link

robinvandenbogaard commented Jan 28, 2023

@bitwiseman the PR #1604, for this issue, closed the PR #1579 instead of issue #1579 (same number).

The PR #1579 addresses issue #1549. Wich now has a automatically closed PR with good fix (opiniated).

Please close this issue as it it addressed by #1604.
Please reopen PR #1579 and address it when you see fit.

@michael-s-grant
Copy link
Contributor Author

michael-s-grant commented Jan 30, 2023

Sorry about the confusion between pull request and issue numbers; this seems to derive from the instructions when opening a pull request 'If this PR fixes one or more issues, include "Fixes #" lines for each issue."' But "#" causes GitHub to introduce a link to the appropriately-numbered pull request, not issue. I suggest you modify the instructions for pull requests.

@robinvandenbogaard: FYI, this issue is not yet ready to be closed; it requires two pull requests, only one of which has been submitted so far.

@michael-s-grant
Copy link
Contributor Author

I don't quite understand how my pull request in hub4-test-org/github-api ended up being merged into hub4/github-api rather than the originating repository. I'm happy to run with the result, but it does mean my test runs against a different repository to all the others.

Anyhow, I have now tested and implemented my change, and recorded a Wiremock snapshot of the data. Now I just need permission to push to hub4j/github-api too and I will submit a pull request.

@bitwiseman
Copy link
Member

I merged it by mistake. hub4j-test-org/github-api is a fork of hub4j/github-api, so PRs for branches in that repo default to targeting hub4j. Sorry, my bad. I'll revert it. Do make your tests run against hub4j-test-org. Because of your permissions in hub4j-test-org, you can push directly to main in that repo. No PR needed.

You shouldn't need more permissions to submit a PR for your feature to hub4j. Push your changes to your personal fork of github-api and do a PR from there.

@michael-s-grant
Copy link
Contributor Author

Fair enough. I'm not used to working with forks in this way.

@michael-s-grant
Copy link
Contributor Author

I have created a pull request now. Note that there seems to be a general problem in the tests (meaning I could replicate it with a test other than the one I created for my code, by temporarily deleting the Wiremock data), which seems to be the result of the JSON returned by fetching the repository being truncated, and hence not valid JSON. This problem is intermittent, but occurs most of the time; since, however, it is out of the scope of this issue, I have not endeavoured to fix it.

Here is a stack trace, should you find it helpful:

org.kohsuke.github.HttpException: Server returned HTTP response code: 200, message: 'null' for URL: http://localhost:57673/repos/hub4j-test-org/github-api

at org.kohsuke.github.GitHubClient.interpretApiError(GitHubClient.java:612)
at org.kohsuke.github.GitHubClient.sendRequest(GitHubClient.java:450)
at org.kohsuke.github.GitHubClient.sendRequest(GitHubClient.java:403)
at org.kohsuke.github.Requester.fetch(Requester.java:85)
at org.kohsuke.github.GHRepository.read(GHRepository.java:145)
at org.kohsuke.github.GHPerson.getRepository(GHPerson.java:156)
at org.kohsuke.github.GHCodeownersErrorTest.getRepository(GHCodeownersErrorTest.java:47)
at org.kohsuke.github.GHCodeownersErrorTest.testGetCodeownersErrors(GHCodeownersErrorTest.java:20)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.kohsuke.github.junit.WireMockMultiServerRule$1.evaluate(WireMockMultiServerRule.java:113)
at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63)
at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69)
at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33)
at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:235)
at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54)
Caused by: com.fasterxml.jackson.databind.JsonMappingException: Unexpected end-of-input: was expecting closing quote for a string value
at [Source: (String)"{"id":206888201,"node_id":"MDEwOlJlcG9zaXRvcnkyMDY4ODgyMDE=","name":"github-api","full_name":"hub4j-test-org/github-api","private":false,"owner":{"login":"hub4j-test-org","id":7544739,"node_id":"MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=","avatar_url":"https://avatars.githubusercontent.com/u/7544739?v=4","gravatar_id":"","url":"http://localhost:57673/users/hub4j-test-org","html_url":"https://github.com/hub4j-test-org","followers_url":"http://localhost:57673/users/hub4j-test-org/followers","following_url":"[truncated 7692 chars]; line: 1, column: 8193] (through reference chain: org.kohsuke.github.GHRepository["parent"])
at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:402)
at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:361)
at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.wrapAndThrow(BeanDeserializerBase.java:1826)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:394)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:185)
at com.fasterxml.jackson.databind.deser.DefaultDeserializationContext.readRootValue(DefaultDeserializationContext.java:323)
at com.fasterxml.jackson.databind.ObjectReader._bindAndClose(ObjectReader.java:2105)
at com.fasterxml.jackson.databind.ObjectReader.readValue(ObjectReader.java:1546)
at org.kohsuke.github.GitHubResponse.parseBody(GitHubResponse.java:104)
at org.kohsuke.github.Requester.lambda$fetch$1(Requester.java:85)
at org.kohsuke.github.GitHubClient.createResponse(GitHubClient.java:549)
at org.kohsuke.github.GitHubClient.sendRequest(GitHubClient.java:436)
... 34 more
Caused by: com.fasterxml.jackson.core.io.JsonEOFException: Unexpected end-of-input: was expecting closing quote for a string value
at [Source: (String)"{"id":206888201,"node_id":"MDEwOlJlcG9zaXRvcnkyMDY4ODgyMDE=","name":"github-api","full_name":"hub4j-test-org/github-api","private":false,"owner":{"login":"hub4j-test-org","id":7544739,"node_id":"MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=","avatar_url":"https://avatars.githubusercontent.com/u/7544739?v=4","gravatar_id":"","url":"http://localhost:57673/users/hub4j-test-org","html_url":"https://github.com/hub4j-test-org","followers_url":"http://localhost:57673/users/hub4j-test-org/followers","following_url":"[truncated 7692 chars]; line: 1, column: 8193]
at com.fasterxml.jackson.core.base.ParserMinimalBase._reportInvalidEOF(ParserMinimalBase.java:696)
at com.fasterxml.jackson.core.json.ReaderBasedJsonParser._skipString(ReaderBasedJsonParser.java:2266)
at com.fasterxml.jackson.core.json.ReaderBasedJsonParser.nextFieldName(ReaderBasedJsonParser.java:936)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:399)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:185)
at com.fasterxml.jackson.databind.deser.impl.FieldProperty.deserializeAndSet(FieldProperty.java:138)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:392)
... 42 more

@michael-s-grant
Copy link
Contributor Author

Hello. Without wanting to chivvy you, could I remind you that pull request #1610 has been awaiting your approval for the last two weeks, just in case it had slipped off your radar.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants