Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Parse and fix broken github api urls#82

Merged
chondent merged 2 commits intospotify:masterspotify/github-java-client:masterfrom
chondent:fix-invalid-github-urlchondent/github-java-client:fix-invalid-github-urlCopy head branch name to clipboard
Nov 18, 2021
Merged

Parse and fix broken github api urls#82
chondent merged 2 commits intospotify:masterspotify/github-java-client:masterfrom
chondent:fix-invalid-github-urlchondent/github-java-client:fix-invalid-github-urlCopy head branch name to clipboard

Conversation

@chondent
Copy link
Contributor

@chondent chondent commented Nov 8, 2021

If a branch has a percent symbol in it, github will sometimes return a
URI that java's URI object can't parse. This patch ensures that in such
a case we url-escape the branch name.

@codecov
Copy link

codecov bot commented Nov 8, 2021

Codecov Report

Merging #82 (b1b4cf2) into master (6490b72) will increase coverage by 1.37%.
The diff coverage is 80.90%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master      #82      +/-   ##
============================================
+ Coverage     68.83%   70.20%   +1.37%     
- Complexity      198      222      +24     
============================================
  Files            32       36       +4     
  Lines           770      866      +96     
  Branches         33       36       +3     
============================================
+ Hits            530      608      +78     
- Misses          217      233      +16     
- Partials         23       25       +2     
Impacted Files Coverage Δ
.../com/spotify/github/v3/clients/JwtTokenIssuer.java 100.00% <ø> (ø)
...om/spotify/github/v3/clients/RepositoryClient.java 64.15% <0.00%> (-0.67%) ⬇️
...java/com/spotify/github/v3/clients/NoopTracer.java 57.14% <57.14%> (ø)
.../com/spotify/github/opencensus/OpenCensusSpan.java 60.00% <60.00%> (ø)
...va/com/spotify/github/v3/clients/GitHubClient.java 72.84% <64.70%> (-1.93%) ⬇️
...fy/github/v3/exceptions/RequestNotOkException.java 54.54% <66.66%> (+4.54%) ⬆️
...a/com/spotify/github/v3/clients/GitDataClient.java 81.48% <86.36%> (+7.19%) ⬆️
...om/spotify/github/opencensus/OpenCensusTracer.java 100.00% <100.00%> (ø)
...om/spotify/github/v3/repos/BranchDeserializer.java 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update dbabfc3...b1b4cf2. Read the comment docs.

dennisgranath
dennisgranath previously approved these changes Nov 8, 2021
@chondent
Copy link
Contributor Author

chondent commented Nov 9, 2021

Just realised this won't handle branches with forward slashes in the name. Working on a fix.

If a branch has a percent symbol in it, github will sometimes return a
URI that java's URI object can't parse. This patch ensures that in such
a case we url-escape the branch name.
@chondent chondent force-pushed the fix-invalid-github-url branch from a4573e4 to 22bce81 Compare November 9, 2021 10:07
Optional<URI> protectionUrl();
}

class BranchDeserializer extends JsonDeserializer<ImmutableBranch> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could BranchDeserializer class be defined in a separate file (BranchDeserializer.java)?
I understand it compiles just fine and it is a matter of taste... The current code within BranchDeserializer does not look like a data structure definition for example, but rather a utility class.
The code might be cleaner if class is defined within its own java file and it would allow for reusability (if needed).
This is just a comment.

Copy link
Contributor

@Abhi347 Abhi347 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@chondent chondent merged commit 78d6981 into spotify:master Nov 18, 2021
dziemba added a commit that referenced this pull request Apr 13, 2022
In #82 we
added a custom deserializer for the `Branch` class.

This deserializer didn't handle certain cases properly that the GH API
would return. In particular the case where the `protected` field was set
and no `protection_url` is present would lead to a NPE in the
deserializer.

To avoid this error and make the whole parser more resilient to
different API results, let's reduce the scope of the custom deserializer
to only parse the `protection_url` field instead of the whole `Branch`
class.

There should be no change in runtime behavior apart from fixing the
error cases.
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 this pull request may close these issues.

4 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.