different-ai/openwork · error

Failed to load GitHub repositories (${response.status}).

Error message

Failed to load GitHub repositories (${response.status}).

What it means

useGithubAccountRepositories pages through GET /v1/connectors/github/accounts/{id}/repositories?limit=100 with cursor pagination. On any non-ok response for a page, this error is thrown with the HTTP status embedded; getErrorMessage substitutes a server-provided message when available.

Source

Thrown at ee/apps/den-web/app/(den)/dashboard/_components/integration-data.tsx:580

              id,
              manifestKind,
              marketplacePluginCount: typeof entry.marketplacePluginCount === "number" ? entry.marketplacePluginCount : null,
              name: toRepoName(fullName),
              private: Boolean(entry.private),
            } satisfies IntegrationRepo];
          })
        : [];
      const repositories: IntegrationRepo[] = [];
      let cursor: string | null = null;
      for (let page = 0; page < 30; page += 1) {
        const { response, payload } = await requestJson(
          `/v1/connectors/github/accounts/${encodeURIComponent(connectorAccountId ?? "")}/repositories?limit=100${cursor ? `&cursor=${encodeURIComponent(cursor)}` : ""}`,
          { method: "GET" },
          20000,
        );

        if (!response.ok) {
          throw new Error(getErrorMessage(payload, `Failed to load GitHub repositories (${response.status}).`));
        }

        repositories.push(...parseRepositories(payload));
        const nextCursor = isRecord(payload) ? asString(payload.nextCursor) : null;
        if (!nextCursor) {
          break;
        }
        cursor = nextCursor;
      }
      return repositories;
    },
  });
}

export function useCreateGithubConnectorInstance() {
  const queryClient = useQueryClient();
  const { runReauthableAction } = useOrgDashboard();

View on GitHub (pinned to 2b7df46e8a)

Solutions

  1. Check the embedded status: 401/403 → re-authenticate and confirm the GitHub installation still exists; 404 → verify connectorAccountId is set; 429 → wait and retry; 5xx → check server proxy logs.
  2. Reinstall/refresh the GitHub App if the installation was revoked.
  3. Retry later if rate-limited — the query layer refetches automatically on window focus in most setups.
  4. Ensure connectorAccountId is non-empty before invoking the query to avoid a malformed URL.

Example fix

// before
if (!response.ok) {
  throw new Error(getErrorMessage(payload, `Failed to load GitHub repositories (${response.status}).`));
}
// after
if (!response.ok) {
  if (response.status === 429) throw new RetriableError(getErrorMessage(payload, `Failed to load GitHub repositories (${response.status}).`));
  throw new Error(getErrorMessage(payload, `Failed to load GitHub repositories (${response.status}).`));
}
Defensive patterns

Strategy: retry

Validate before calling

if (!connectorAccountId) {
  // don't call the API with an empty id — it will 404
  throw new Error("No connector account id; cannot load repositories.");
}

Type guard

function isNonEmptyId(v: string | null | undefined): v is string {
  return typeof v === "string" && v.length > 0;
}

Try / catch

try {
  await repositoriesQuery;
} catch (e) {
  const msg = e instanceof Error ? e.message : String(e);
  if (/\(429\)/.test(msg) || /\(50[0-9]\)/.test(msg)) {
    retryWithBackoff(() => repositoriesQuery.refetch(), 3);
  } else if (/\(40[134]\)/.test(msg)) {
    showReinstallPrompt(); // installation likely revoked or account gone
  } else {
    setError(msg);
  }
}

Prevention

When it happens

Trigger: GET repositories returns 401/403 (session expired or GitHub installation revoked), 404 (connectorAccountId empty or account deleted), 429 (GitHub API rate limit relayed by the server), or 5xx while the server proxies GitHub's API.

Common situations: User uninstalled the GitHub App from their org so the server can no longer list repos; GitHub API secondary rate limit hit during pagination; connectorAccountId undefined because account data loaded out of order.

Understand the failure class

Background: 'Something went wrong' / 'Request failed (500)' / 'HTTP error! status: 404' — what failed HTTP requests actually mean and how to find the real cause — this error's family across 28 libraries.

Related errors


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