Skip to content

Commit 3f23ebc

Browse files
committed
BUG PullRequest id can be bigger than Integer.MAX
Represent the id as Long instead of Integer. Official Schema for Pull Request -> int64: https://docs.github.com/en/rest/pulls/pulls?apiVersion=2022-11-28#list-pull-requests
1 parent 2efaac3 commit 3f23ebc

File tree

3 files changed

+405
-1
lines changed

3 files changed

+405
-1
lines changed

src/main/java/com/spotify/github/v3/prs/PullRequestItem.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public interface PullRequestItem extends CloseTracking {
4343

4444
/** ID. */
4545
@Nullable
46-
Integer id();
46+
Long id();
4747

4848
/** URL. */
4949
@Nullable

src/test/java/com/spotify/github/v3/prs/PullRequestTest.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ public void testDeserializationPr() throws IOException {
3838
String fixture =
3939
Resources.toString(getResource(this.getClass(), "pull_request.json"), defaultCharset());
4040
final PullRequest pr = Json.create().fromJson(fixture, PullRequest.class);
41+
42+
assertThat(pr.id(), is(1L));
4143
assertThat(pr.mergeCommitSha().get(), is("e5bd3914e2e596debea16f433f57875b5b90bcd6"));
4244
assertThat(pr.merged(), is(false));
4345
assertThat(pr.mergeable().get(), is(true));
@@ -48,6 +50,19 @@ public void testDeserializationPr() throws IOException {
4850
assertThat(pr.draft(), is(Optional.of(false)));
4951
}
5052

53+
@Test
54+
public void testDeserializationPrWithLargeId() throws IOException {
55+
String fixture =
56+
Resources.toString(getResource(this.getClass(), "pull_request_long_id.json"), defaultCharset());
57+
final PullRequest pr = Json.create().fromJson(fixture, PullRequest.class);
58+
59+
assertThat(pr.id(), is(2459198527L));
60+
assertThat(pr.head().sha(), is("f74c7f420282f584acd2fb5964202e5b525c3ab8"));
61+
assertThat(pr.merged(), is(false));
62+
assertThat(pr.mergeable().get(), is(false));
63+
assertThat(pr.draft(), is(Optional.of(true)));
64+
}
65+
5166
@Test
5267
public void testSerializationMergeParams() throws IOException {
5368
String fixture =

0 commit comments

Comments
 (0)