different-ai/openwork · error · PluginArchRouteFailure

github_connector_request_failed

github_connector_request_failed

Error message

${error.message}

What it means

wrapGithubConnectorError converts GithubConnectorRequestError into a 409 github_connector_request_failed with the underlying message attached as cause. This means a request to GitHub's API from the connector failed — network error, 4xx/5xx from GitHub, or timeout — not a local config problem. The original error is preserved for server-side inspection.

Source

Thrown at ee/apps/den-api/src/routes/org/plugin-system/store.ts:4357

export function consumeGithubInstallState(state: string) {
  const parsed = verifyGithubInstallStateToken({ secret: env.betterAuthSecret, token: state })
  if (!parsed) {
    throw new PluginArchRouteFailure(400, "invalid_github_install_state", "GitHub install state is invalid or expired.")
  }
  return parsed
}

function wrapGithubConnectorError(error: unknown): never {
  if (error instanceof PluginArchRouteFailure) {
    throw error
  }

  if (error instanceof GithubConnectorConfigError) {
    throw new PluginArchRouteFailure(409, "github_connector_app_not_configured", error.message)
  }

  if (error instanceof GithubConnectorRequestError) {
    throw new PluginArchRouteFailure(409, "github_connector_request_failed", error.message, { cause: error })
  }

  throw error
}

function normalizeDiscoveryCursor(value: string | undefined) {
  return value?.trim() || undefined
}

function discoveryStep(status: GithubConnectorDiscoveryStep["status"], id: GithubConnectorDiscoveryStep["id"], label: string): GithubConnectorDiscoveryStep {
  return { id, label, status }
}

function buildGithubConnectorDiscoverySteps(input: {
  classification: GithubDiscoveryClassification
  discoveredPlugins: GithubDiscoveredPlugin[]
}) {
  return [

View on GitHub (pinned to 2b7df46e8a)

Solutions

  1. Read error.message/cause to see the GitHub-side status or network error and address it specifically
  2. Check server egress connectivity to https://api.github.com and https://github.com (proxy/firewall rules)
  3. Verify the GitHub App still exists, is not suspended, and credentials are valid
  4. Retry after backoff for transient 5xx/rate-limit responses; check the GitHub status page

Example fix

// before
await exchangeCodeForToken(code) // raw failure propagates as 409
// after
try {
  await exchangeCodeForToken(code)
} catch (e) {
  if (isGithubConnectorRequestError(e) && e.status === 403 && e.rateLimited) {
    await sleep(backoffFor(e.resetAt)); return exchangeCodeForToken(code)
  }
  throw e
}
Defensive patterns

Strategy: retry

Validate before calling

// cheap reachability pre-check for egress-restricted environments
const ok = await fetch("https://api.github.com/zen", { signal: AbortSignal.timeout(5000) })
  .then((r) => r.ok).catch(() => false)
if (!ok) throw new Error("GitHub API unreachable from server — check egress/proxy")

Type guard

function isGithubConnectorRequestError(e: unknown): boolean {
  return e instanceof PluginArchRouteFailure && e.code === "github_connector_request_failed"
}
function isGithubConnectorRequestErrorRaw(e: unknown): e is GithubConnectorRequestError {
  return e instanceof GithubConnectorRequestError
}

Try / catch

try {
  return await githubConnectorOperation(args)
} catch (e) {
  if (isGithubConnectorRequestError(e)) {
    log.error("github request failed", { cause: e.cause })
    if (isRetryable(e.cause)) return retryWithBackoff(() => githubConnectorOperation(args))
    return respond(502, "GitHub request failed: " + e.message)
  }
  throw e
}

Prevention

When it happens

Trigger: GitHub connector operations (token exchange, installation lookup, API calls) where fetch to github.com failed: network unreachable, GitHub returned an error status, TLS issues, or rate limiting surfaced as GithubConnectorRequestError.

Common situations: Egress firewall blocking api.github.com from the server; GitHub App credentials revoked causing 401/404 from GitHub; GitHub rate limits during bulk install syncs; transient GitHub incidents.

Related errors


AI-assisted analysis of different-ai/openwork@2b7df46e8a (2026-09-01). Data as JSON: /api/errors/17f666a3b13d3b7d. Report an issue: GitHub.