{"record":{"id":"caf596318d728d89","repo":"decolua/9router","slug":"onboarduser-http-response-status-errortext-s","errorCode":null,"errorMessage":"onboardUser HTTP ${response.status}: ${errorText.slice(0, 200)}","messagePattern":"onboardUser HTTP (.+?): (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"open-sse/services/projectId.js","lineNumber":230,"sourceCode":"        // Per-attempt timeout controller; forwards external abort as well\n        const localCtrl = new AbortController();\n        const timeoutId = setTimeout(() => localCtrl.abort(), 30_000);\n        const forwardAbort = () => localCtrl.abort();\n        externalSignal?.addEventListener(\"abort\", forwardAbort);\n\n        try {\n            const response = await fetch(endpoints.onboardUser, {\n                method: \"POST\",\n                headers: { ...headers, \"Authorization\": `Bearer ${accessToken}` },\n                body: JSON.stringify(reqBody),\n                signal: localCtrl.signal\n            });\n\n            clearTimeout(timeoutId);\n\n            if (!response.ok) {\n                const errorText = await response.text().catch(() => \"\");\n                throw new Error(`onboardUser HTTP ${response.status}: ${errorText.slice(0, 200)}`);\n            }\n\n            const data = await response.json();\n\n            if (data.done === true) {\n                const projectId = extractProjectIdFromOnboard(data);\n                if (projectId) {\n                    console.log(`[ProjectId] Successfully onboarded, project ID: ${projectId}`);\n                    return projectId;\n                }\n                throw new Error(\"onboardUser done but no project_id in response\");\n            }\n\n            // Server not done yet – wait and retry\n            console.log(`[ProjectId] Onboard attempt ${attempt}/${MAX_ATTEMPTS}: not done yet, waiting...`);\n            await new Promise(resolve => setTimeout(resolve, 2000));\n\n        } catch (error) {","sourceCodeStart":212,"sourceCodeEnd":248,"githubUrl":"https://github.com/decolua/9router/blob/90b52e06ffd666b7929554211474d01588f6b1f8/open-sse/services/projectId.js#L212-L248","documentation":"When loadCodeAssist indicates the account is not yet onboarded, fetchProjectId calls the onboardUser endpoint and polls it. This error is thrown when the onboardUser HTTP response is not OK, carrying the status and first 200 chars of the error body. It means Google refused the onboarding request itself.","triggerScenarios":"The onboardUser POST returns a non-2xx status after the polling request — 401/403 from bad/expired credentials, 429 from too many onboard attempts, or 5xx from Google.","commonSituations":"Brand-new Gemini/Code Assist account that Google refuses to onboard (quota/abuse limits); access token expiring mid-poll; regional availability restrictions on Cloud Code onboarding.","solutions":["Re-authorize the account to obtain a fresh access token before onboarding","Read the embedded error body for the Google error reason and address it (quota, permission, region)","Reduce onboard polling pressure — the code already waits 2s between attempts; wait for any rate-limit window to pass and retry","Verify proxy/network path to cloudcode-pa.googleapis.com is not intercepted or blocked"],"exampleFix":"// before\nawait onboardUser(accessToken, proxyOptions);\n// after\ntry {\n  await onboardUser(accessToken, proxyOptions);\n} catch (e) {\n  if (/HTTP 429/.test(e.message)) {\n    await sleep(60_000);\n    await onboardUser(accessToken, proxyOptions);\n  } else throw e;\n}","handlingStrategy":"retry","validationCode":"if (!accessToken) throw new Error('Authorize the account before onboarding.');","typeGuard":"function canOnboard(t) { return typeof t === 'string' && t.length > 0; }","tryCatchPattern":"try {\n  await onboardUser(accessToken, proxyOptions);\n} catch (e) {\n  if (/HTTP 429/.test(e.message)) { await sleep(60_000); return onboardUser(accessToken, proxyOptions); }\n  if (/HTTP (401|403)/.test(e.message)) { await reauthorize(conn); return onboardUser(await getToken(conn), proxyOptions); }\n  throw e;\n}","preventionTips":["Complete Google account onboarding once manually before automating it","Back off on 429 — onboardUser already polls at 2s intervals; do not tighten it","Keep tokens fresh across the whole polling loop (a long poll can outlive token TTL)","Confirm Cloud Code availability in your region/account tier"],"tags":["network","http","oauth","google-cloud"],"backgroundTag":"http-error-response","analyzedSha":"90b52e06ffd666b7929554211474d01588f6b1f8","analyzedAt":"2026-08-30T21:05:45.952Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}