Skip to content

Commit 51d5a26

Browse files
[Fix] Resolves issue with GitHub App Auto Creation (#1153)
1 parent 65a700d commit 51d5a26

2 files changed

Lines changed: 17 additions & 2 deletions

File tree

app/Actions/GithubApp/CreateGithubAppFromManifest.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use App\Actions\Bootstrap\GetBootstrap;
66
use App\Models\GithubApp;
77
use Illuminate\Support\Facades\Http;
8+
use Illuminate\Support\Facades\Log;
89
use Illuminate\Validation\ValidationException;
910

1011
class 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
}

tests/Feature/GithubAppTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,11 @@ public function test_manifest_callback_creates_app(): void
7777
'app_id' => 12345,
7878
'app_slug' => 'vito-test',
7979
]);
80+
81+
Http::assertSent(function ($request) {
82+
return $request->url() === 'https://api.github.com/app-manifests/test-code/conversions'
83+
&& $request->body() === '';
84+
});
8085
}
8186

8287
public function test_manifest_callback_rejects_missing_code(): void

0 commit comments

Comments
 (0)