Skip to content

Commit 4627265

Browse files
committed
Fix fine-grained handling of errors in backport management.
1 parent eb647e5 commit 4627265

File tree

3 files changed

+18
-14
lines changed

3 files changed

+18
-14
lines changed

bot-components/GitHub_queries.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -992,7 +992,7 @@ let get_project_field_values ~bot_info ~organization ~project ~field ~options =
992992
let open GitHub_GraphQL.GetProjectFieldValues in
993993
makeVariables ~organization ~project ~field ~options ()
994994
|> serializeVariables |> variablesToJson
995-
|> send_graphql_query ~bot_info ~query
995+
|> send_graphql_query ~bot_info ~query ~ignore_errors:true
996996
~parse:(Fn.compose parse unsafe_fromJson)
997997
>>= function
998998
| Ok result -> (

bot-components/GraphQL_query.ml

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ open Utils
44

55
type api = GitHub | GitLab of string
66

7-
let send_graphql_query ~bot_info ?(extra_headers = []) ~api ~query ~parse
8-
variables =
7+
let send_graphql_query ~bot_info ?(extra_headers = []) ?(ignore_errors = false)
8+
~api ~query ~parse variables =
99
let uri =
1010
( match api with
1111
| GitLab gitlab_domain ->
@@ -46,17 +46,20 @@ let send_graphql_query ~bot_info ?(extra_headers = []) ~api ~query ~parse
4646
let json = Yojson.Basic.from_string body in
4747
let open Yojson.Basic.Util in
4848
let data = json |> member "data" |> parse in
49-
match member "errors" json with
50-
| `Null ->
51-
Ok data
52-
| errors ->
53-
let errors =
54-
to_list errors
55-
|> List.map ~f:(fun error -> error |> member "message" |> to_string)
56-
in
57-
Error
58-
( "Server responded to GraphQL request with errors: "
59-
^ String.concat ~sep:", " errors )
49+
if ignore_errors then Ok data
50+
else
51+
match member "errors" json with
52+
| `Null ->
53+
Ok data
54+
| errors ->
55+
let errors =
56+
to_list errors
57+
|> List.map ~f:(fun error ->
58+
error |> member "message" |> to_string )
59+
in
60+
Error
61+
( "Server responded to GraphQL request with errors: "
62+
^ String.concat ~sep:", " errors )
6063
with
6164
| Failure err ->
6265
Error (f "Exception: %s" err)

bot-components/GraphQL_query.mli

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ type api = GitHub | GitLab of string
33
val send_graphql_query :
44
bot_info:Bot_info.t
55
-> ?extra_headers:(string * string) list
6+
-> ?ignore_errors:bool
67
-> api:api
78
-> query:string
89
-> parse:(Yojson.Basic.t -> 'a)

0 commit comments

Comments
 (0)