@@ -170,10 +170,31 @@ async fn linked_build(stats: serde_json::Value) -> laravel::Result<Build> {
170170 Ok ( build)
171171}
172172
173+ /// GitHub's rules for a check run's body (its REST schema): `conclusion`, when there, is one of its values and never
174+ /// null, and a completed check has one. GitHub answers 422 otherwise, as it did to every check waiting for review on
175+ /// 3 Dec 2026 (`"conclusion": null`).
176+ fn github_check_run_problem ( body : & serde_json:: Value ) -> Option < String > {
177+ const CONCLUSIONS : [ & str ; 7 ] =
178+ [ "success" , "failure" , "neutral" , "cancelled" , "timed_out" , "action_required" , "skipped" ] ;
179+ let status = body[ "status" ] . as_str ( ) . unwrap_or ( "queued" ) ;
180+ match body. get ( "conclusion" ) {
181+ Some ( serde_json:: Value :: String ( c) ) if CONCLUSIONS . contains ( & c. as_str ( ) ) => None ,
182+ Some ( other) => Some ( format ! ( "For properties/conclusion, {other} is not a member of {CONCLUSIONS:?}" ) ) ,
183+ None if status == "completed" => Some ( "a completed check run needs a conclusion" . to_string ( ) ) ,
184+ None => None ,
185+ }
186+ }
187+
173188fn github ( ) -> client:: HttpFake {
174189 client:: fake ( )
175190 . with ( "api.github.com/app/installations/7/access_tokens" , json ! ( { "token" : "t" } ) )
176- . with ( "api.github.com/repos/acme/web/check-runs" , json ! ( { "id" : 900 } ) )
191+ . with ( "api.github.com/repos/acme/web/check-runs" , |request : & client:: Request | {
192+ let body: serde_json:: Value = request. json ( ) . unwrap_or_default ( ) ;
193+ match github_check_run_problem ( & body) {
194+ Some ( problem) => client:: response ( ) . status ( 422 ) . json ( json ! ( { "message" : problem } ) ) ,
195+ None => client:: response ( ) . json ( json ! ( { "id" : 900 } ) ) ,
196+ }
197+ } )
177198 . with ( "api.github.com/repos/acme/web/issues/5/comments" , json ! ( { "id" : 700 } ) )
178199}
179200
@@ -189,6 +210,7 @@ async fn a_changed_build_gets_a_waiting_check_and_a_comment(_app: Application) -
189210 assert_eq ! ( check[ "name" ] , "VisualCI" ) ;
190211 assert_eq ! ( check[ "head_sha" ] , "abc123" ) ;
191212 assert_eq ! ( check[ "status" ] , "in_progress" ) ;
213+ assert ! ( check. get( "conclusion" ) . is_none( ) , "no conclusion yet, so none sent (GitHub refuses null): {check}" ) ;
192214 assert_eq ! ( check[ "output" ] [ "title" ] , "1 changes waiting for review" ) ;
193215 assert ! ( check[ "output" ] [ "summary" ] . as_str( ) . unwrap( ) . contains( "**To review:**" ) , "{check}" ) ;
194216 let comment = sent. iter ( ) . find ( |r| r. url ( ) . ends_with ( "/issues/5/comments" ) ) . expect ( "a comment" ) ;
@@ -316,3 +338,22 @@ fn the_comments_hash_leaves_out_its_images_signatures() {
316338 assert_eq ! ( body_hash( a) , body_hash( b) ) ;
317339 assert_ne ! ( body_hash( a) , body_hash( & a. replace( "ab12" , "cd34" ) ) , "another image is another body" ) ;
318340}
341+
342+ /// A check or comment the forge kept refusing until it used up its retries shows on /status (and the metrics), so it
343+ /// alerts instead of leaving a pull request waiting for a check that never comes (3 Dec 2026).
344+ #[ laravel:: test]
345+ async fn refused_checks_show_on_the_status ( app : Application ) -> laravel:: Result < ( ) > {
346+ assert_eq ! ( app. get( "/status" ) . await . json( ) [ "forge_posts_failed" ] , 0 ) ;
347+ let job = laravel:: str:: uuid7 ( ) . to_string ( ) ;
348+ let payload = r#"{"displayName":"forge.check","data":{"build_id":91}}"# ;
349+ db:: query!(
350+ "INSERT INTO failed_jobs (job_id, connection, queue, payload, error, failed_at) \
351+ VALUES ({job}, 'database', 'default', {payload}, 'GitHub check run: HTTP 422', now())"
352+ )
353+ . update ( )
354+ . await ?;
355+ let status = app. get ( "/status" ) . await . json ( ) . clone ( ) ;
356+ assert_eq ! ( status[ "forge_posts_failed" ] , 1 , "{status}" ) ;
357+ assert_eq ! ( status[ "forge_posts_retrying" ] , 0 , "{status}" ) ;
358+ Ok ( ( ) )
359+ }
0 commit comments