{"record":{"id":"8844dd12eef14025","repo":"diegosouzapw/OmniRoute","slug":"gheurl-is-required-for-ghe-copilot-oauth","errorCode":null,"errorMessage":"gheUrl is required for GHE Copilot OAuth","messagePattern":"gheUrl is required for GHE Copilot OAuth","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/lib/oauth/providers/ghe-copilot.ts","lineNumber":15,"sourceCode":"import { GHE_COPILOT_CONFIG } from \"../constants/oauth\";\nimport { sanitizeErrorMessage } from \"@omniroute/open-sse/utils/error\";\n\n/**\n * GHE Copilot OAuth provider.\n *\n * Reuses the GitHub device-code flow but targets the GitHub Enterprise host\n * configured per-connection via `gheUrl` (stored in providerSpecificData).\n * The device-code / token / user-info / copilot-token endpoints are derived\n * from gheUrl at request time.\n */\n\nfunction normalizeGheUrl(value: unknown): string {\n  if (typeof value !== \"string\" || !value.trim()) {\n    throw new Error(\"gheUrl is required for GHE Copilot OAuth\");\n  }\n  return value.trim().replace(/\\/+$/, \"\");\n}\n\nexport const gheCopilot = {\n  config: GHE_COPILOT_CONFIG,\n  flowType: \"device_code\" as const,\n  requestDeviceCode: async (config: any) => {\n    const gheUrl = normalizeGheUrl(config.gheUrl);\n    const response = await fetch(`${gheUrl}/login/device/code`, {\n      method: \"POST\",\n      headers: {\n        \"Content-Type\": \"application/x-www-form-urlencoded\",\n        Accept: \"application/json\",\n      },\n      body: new URLSearchParams({\n        client_id: config.clientId,\n        scope: config.scopes,","sourceCodeStart":1,"sourceCodeEnd":33,"githubUrl":"https://github.com/diegosouzapw/OmniRoute/blob/a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d/src/lib/oauth/providers/ghe-copilot.ts#L1-L33","documentation":"normalizeGheUrl() in the GHE Copilot provider: the per-connection gheUrl value is missing, not a string, or blank. Every GHE endpoint (device code, token, user info) is derived from it, so the flow cannot proceed without it.","triggerScenarios":"Thrown at src/lib/oauth/providers/ghe-copilot.ts:15 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Set the GitHub Enterprise URL on the connection before authorizing","Validate gheUrl presence in the UI before offering the OAuth button"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d","analyzedAt":"2026-08-25T18:35:09.898Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}