55use App \Actions \Bootstrap \GetBootstrap ;
66use App \Models \GithubApp ;
77use Illuminate \Support \Facades \Http ;
8+ use Illuminate \Support \Facades \Log ;
89use Illuminate \Validation \ValidationException ;
910
1011class CreateGithubAppFromManifest
@@ -20,12 +21,21 @@ public function create(string $code): GithubApp
2021 $ response = Http::withHeaders ([
2122 'Accept ' => 'application/vnd.github+json ' ,
2223 'X-GitHub-Api-Version ' => '2022-11-28 ' ,
23- ])->post ("https://api.github.com/app-manifests/ {$ code }/conversions " );
24+ 'User-Agent ' => 'Vito ' ,
25+ ])->send ('POST ' , "https://api.github.com/app-manifests/ {$ code }/conversions " );
2426
2527 if (! $ response ->successful ()) {
28+ Log::error ('GitHub App manifest conversion failed ' , [
29+ 'status ' => $ response ->status (),
30+ 'body ' => $ response ->body (),
31+ ]);
32+
33+ $ message = (string ) ($ response ->json ('message ' ) ?? '' );
34+
2635 throw ValidationException::withMessages ([
27- 'github_app ' => __ ('Failed to convert manifest (HTTP :status). ' , [
36+ 'github_app ' => __ ('Failed to convert manifest (HTTP :status):status_message . ' , [
2837 'status ' => $ response ->status (),
38+ 'status_message ' => $ message !== '' ? ' ' .$ message : '' ,
2939 ]),
3040 ]);
3141 }
0 commit comments