Skip to content

Commit 84ed0c9

Browse files
Issue #22228 - Flakiness when running create-pr (PR #41)
* Improve error handling for pull request connection mutations * Bump up version
1 parent 0b2ba9e commit 84ed0c9

2 files changed

Lines changed: 17 additions & 3 deletions

File tree

src/main/kotlin/zenhub/ZenHubClient.kt

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -505,13 +505,27 @@ class ZenHubClient(val zenhubWorkspaceId: String = DEFAULT_WORKSPACE_ID) : AutoC
505505
fun createIssuePrConnection(issueId: String, pullRequestID: String) = runBlocking {
506506
val input = CreateIssuePrConnectionInput(Optional.absent(), issueId, pullRequestID)
507507
val mutation = CreateIssuePrConnectionMutation(input)
508-
apolloClient.mutation(mutation).execute()
508+
val response = apolloClient.mutation(mutation).execute()
509+
510+
if (response.hasErrors()) {
511+
val message = response.errors!!.joinToString { it.message }
512+
throw RuntimeException("GraphQL request failed: $message")
513+
}
514+
515+
response.data ?: throw IllegalStateException("GraphQL returned no data and no errors")
509516
}
510517

511518
fun deleteIssuePrConnection(issueId: String, pullRequestID: String) = runBlocking {
512519
val input = DeleteIssuePrConnectionInput(Optional.absent(), issueId, pullRequestID)
513520
val mutation = DeleteIssuePrConnectionMutation(input)
514-
apolloClient.mutation(mutation).execute()
521+
val response = apolloClient.mutation(mutation).execute()
522+
523+
if (response.hasErrors()) {
524+
val message = response.errors!!.joinToString { it.message }
525+
throw RuntimeException("GraphQL request failed: $message")
526+
}
527+
528+
response.data ?: throw IllegalStateException("GraphQL returned no data and no errors")
515529
}
516530

517531
fun addAssigneesToIssues(issueIds: List<String>, assigneeIds: List<String>) = runBlocking {

version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
8.2.0
1+
8.3.0

0 commit comments

Comments
 (0)