Skip to content

Commit d1628e8

Browse files
committed
chore(submit): log GitHub response headers on PR error
Add x-github-sso, x-oauth-scopes and x-accepted-oauth-scopes to the error log to disambiguate a write 404 (SAML SSO vs scope mismatch vs plain permission block).
1 parent 7c77479 commit d1628e8

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

_config/ui/app/api/submit/route.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,15 +220,21 @@ export async function POST(request: Request): Promise<Response> {
220220
status?: number;
221221
message?: string;
222222
request?: {method?: string; url?: string};
223-
response?: {data?: unknown};
223+
response?: {data?: unknown; headers?: Record<string, string | undefined>};
224224
};
225225
// Expand the octokit HttpError: default logging collapses request/response to "[Object]", hiding
226226
// exactly which GitHub call 404'd (fork? createRef? on which owner/repo?) and GitHub's own message.
227+
// The response headers disambiguate a write 404: SAML SSO (x-github-sso), an OAuth scope mismatch
228+
// (x-accepted-oauth-scopes vs x-oauth-scopes), or a plain permission block.
229+
const responseHeaders = httpError.response?.headers || {};
227230
console.error('createPullRequest failed', {
228231
status: httpError.status,
229232
request: `${httpError.request?.method} ${httpError.request?.url}`,
230233
message: httpError.message,
231-
ghError: JSON.stringify(httpError.response?.data)
234+
ghError: JSON.stringify(httpError.response?.data),
235+
sso: responseHeaders['x-github-sso'],
236+
oauthScopes: responseHeaders['x-oauth-scopes'],
237+
acceptedOauthScopes: responseHeaders['x-accepted-oauth-scopes']
232238
});
233239
const status = httpError.status;
234240
const message = httpError.message || '';

0 commit comments

Comments
 (0)