{"record":{"id":"6916452b2cbd3904","repo":"odysseus-dev/odysseus","slug":"login-succeeded-but-provisioning-failed-e","errorCode":null,"errorMessage":"Login succeeded but provisioning failed: {e}","messagePattern":"Login succeeded but provisioning failed: (.+?)","errorType":"http","errorClass":"HTTPException","httpStatus":500,"severity":"error","filePath":"routes/copilot_routes.py","lineNumber":152,"sourceCode":"        interval=int(data.get(\"interval\") or 5),\n        expires_in=int(data.get(\"expires_in\") or 900),\n    )\n\n\ndef _poll_device_flow(_request: Request, pending: Dict) -> DeviceFlowPoll:\n    try:\n        data = copilot.poll_access_token(pending[\"host\"], pending[\"device_code\"])\n    except Exception as e:\n        return DeviceFlowPoll.pending(f\"poll error: {e}\")\n\n    token = data.get(\"access_token\")\n    if token:\n        base = copilot.enterprise_base(pending[\"enterprise_url\"]) if pending[\"enterprise_url\"] else copilot.COPILOT_BASE\n        try:\n            result = _provision_endpoint(token, base, pending[\"owner\"])\n        except Exception as e:\n            logger.exception(\"Copilot endpoint provisioning failed\")\n            raise HTTPException(500, f\"Login succeeded but provisioning failed: {e}\")\n        return DeviceFlowPoll.authorized(result)\n\n    err = data.get(\"error\")\n    if err == \"authorization_pending\":\n        return DeviceFlowPoll.pending()\n    if err == \"slow_down\":\n        return DeviceFlowPoll.slow_down(int(data.get(\"interval\") or 0) or None)\n    if err in (\"expired_token\", \"access_denied\"):\n        return DeviceFlowPoll.failed(err)\n    # Unknown error — surface but keep the session for another try.\n    return DeviceFlowPoll.pending(err or \"unknown\")\n\n\ndef setup_copilot_routes():\n    return create_device_flow_router(\n        prefix=\"/api/copilot\",\n        tags=[\"copilot\"],\n        store=_DEVICE_FLOW_STORE,","sourceCodeStart":134,"sourceCodeEnd":170,"githubUrl":"https://github.com/odysseus-dev/odysseus/blob/f9235ebbf13f693a6fd29ce70b097f6ec83705bf/routes/copilot_routes.py#L134-L170","documentation":"Raised (HTTP 500) during Copilot device-flow polling after the OAuth half succeeded: poll_access_token returned a valid access_token, but _provision_endpoint(token, base, owner) — which registers/activates the Copilot chat completion endpoint for that user — threw an exception. The GitHub login itself worked; only the follow-up provisioning against the Copilot API (COPILOT_BASE or the enterprise base) failed. The underlying exception is logged via logger.exception before the 500 is raised.","triggerScenarios":"Device poll succeeds in getting a token, then the provisioning call to the Copilot endpoint fails: user has no Copilot subscription/seat (403 from the Copilot API), Copilot service outage, enterprise base URL misconfigured, network failure reaching api.githubcopilot.com.","commonSituations":"User authenticates with a GitHub account that has no Copilot access (no subscription, no org seat); GHES Copilot integration not enabled so the enterprise base 404s; transient Copilot API outage right at login time.","solutions":["Check the server logs — logger.exception('Copilot endpoint provisioning failed') captured the full traceback with the real cause.","Confirm the account actually has a Copilot subscription or org seat before retrying login.","If using enterprise, verify the enterprise_url produces a valid Copilot base (copilot.enterprise_base) and that Copilot is enabled on the instance.","Retry the login once the Copilot service is healthy — the token itself was fine, only provisioning failed."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { poll = await post('/copilot/device/poll', { poll_id }); } catch (e) { if (e.status === 500 && /provisioning failed/.test(e.message)) { showBanner('GitHub login worked but Copilot provisioning failed — verify your Copilot subscription and retry.'); return stopPolling(); } throw e; }","preventionTips":["Confirm the account has a Copilot seat before starting device login.","Check server logs for the 'Copilot endpoint provisioning failed' traceback whenever this 500 appears."],"tags":["copilot","provisioning","oauth","subscription","upstream-error"],"backgroundTag":null,"analyzedSha":"f9235ebbf13f693a6fd29ce70b097f6ec83705bf","analyzedAt":"2026-08-14T21:47:48.359Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}