fix: reject non-2xx responses in Fly.io token validation (#1614)

testFlyToken() fallback to /v1/user accepted 404 plain text responses
because hasError() only checks for JSON "error"/"errors" keys. Adding
resp.ok check ensures non-2xx responses are correctly rejected.

Co-authored-by: Claude <claude@anthropic.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
A 2026-02-21 13:47:40 -08:00 committed by GitHub
parent 01e5fa842d
commit d69c4f0f02
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 5 additions and 3 deletions

View file

@ -143,8 +143,10 @@ async function testFlyToken(): Promise<boolean> {
headers: { Authorization: authHeader },
signal: AbortSignal.timeout(10_000),
});
const text = await resp.text();
if (text && !hasError(text)) return true;
if (resp.ok) {
const text = await resp.text();
if (text && !hasError(text)) return true;
}
} catch {
// fall through
}