Maintainer repository sync always fails: GitHubSyncPanel POSTs to /api/github/sync/:owner/:repo, which this app does not serve

Aperta
#831 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
45/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
github, next.js, typescript

Direzione di ricerca

Start with src/app/dashboard/maintainer/GitHubSyncPanel.tsx and the shared request helpers in src/lib/api.ts; confirm the backend sync path and pagination fields before choosing the request URL. Check the existing API call patterns and add focused coverage for the panel’s request origin, authentication, pagination stopping, and 404 message. Done when repository sync reaches the authenticated backend, can be stopped or terminates safely, and reports endpoint failures clearly.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug

Location

src/app/dashboard/maintainer/GitHubSyncPanel.tsx:40-46

Problem

The "Connect repository" panel syncs a repo's issues with:

const url = `/api/github/sync/${encodeURIComponent(owner.trim())}/${encodeURIComponent(repo.trim())}${params.toString() ? `?${params}` : ""}`;
const res = await fetch(url, { method: "POST" });
if (!res.ok) {
  const body = await res.json().catch(() => ({}));
  throw new Error(body.error || `Sync failed (${res.status})`);
}

The URL is relative, so it targets the Next.js app's own origin. Nothing in this repository serves it:

  • The only Route Handler under src/app/ is src/app/sitemaps/[id]/route.ts; there is no src/app/api/ directory.
  • next.config.ts has no rewrites(), so /api/* is not proxied to NEXT_PUBLIC_API_URL.

Every sync attempt therefore gets the Next.js HTML 404. res.json() on an HTML body rejects, the .catch(() => ({})) swallows it, body.error is undefined, and the panel shows the generic Sync failed (404).

Two further problems in the same call, which will matter once the URL is corrected:

  • No credentials. The request sends no Authorization header and no token, unlike every other mutating call in the app, which goes through apiPost/apiRequest in src/lib/api.ts. Syncing a repository is a per-maintainer, authenticated action, so pointing this at the real backend as written would get a 401 rather than a 404.
  • Unbounded pagination loop. Lines 36-51 loop do { ... } while (nextPage) with no iteration cap and no AbortController. A backend that keeps returning the same nextPage cursor — or one that echoes a cursor on an error response — spins forever, firing requests with no way for the user to cancel, since the panel has no stop control.

Why it matters

Repository sync is the entry point for the entire maintainer workflow: src/app/dashboard/maintainer/page.tsx:110 renders an "No repositories connected" empty state until fetchMyRepositories returns something, and the pipeline board stays empty until then. With this call 404ing, a maintainer can never get their issues onto the platform, which is the problem closed issue #637 ("No UI to sync a GitHub repository, so maintainers can't bring their issues onto the platform") was closed on — so #637 has regressed: the UI exists but is wired to a nonexistent endpoint.

The error text also misdirects whoever debugs it. "Sync failed (404)" reads as "that repository does not exist on GitHub", not "this app has no such endpoint".

Reproduction

  1. Sign in as a maintainer and open /dashboard/maintainer.
  2. In the "Connect repository" panel, enter any owner and repo (e.g. stellar / soroban-examples) and click Sync.
  3. DevTools → Network: POST http://localhost:3000/api/github/sync/stellar/soroban-examples returns 404 with content-type: text/html.
  4. The panel renders Sync failed (404) and syncedRepos stays empty.

Suggested fix

  • Route the call through the shared API client so it targets NEXT_PUBLIC_API_URL and carries the session token: use apiPost from src/lib/api.ts (which already handles the token, the timeout/AbortController, and rate-limit/error parsing) instead of a bare fetch. Confirm the backend's actual sync path and its pagination field names before settling on the URL shape.
  • Alternatively add a real src/app/api/github/sync/[owner]/[repo]/route.ts handler that forwards to the backend server-side; if you do, it must read the session itself rather than trusting the client.
  • Cap the pagination loop (for example, stop after N pages or when a nextPage cursor repeats) and thread an AbortController through it so navigating away or clicking a cancel control stops the run.
  • Distinguish a 404 on the endpoint from a 404 on the repository in the message, so the two failures are not reported with identical copy.
  • Add a test for this panel that asserts the request goes to the configured API origin and that a 404 surfaces a specific message; there is currently no GitHubSyncPanel.test.tsx at all.
Lingua principale
TypeScript
Stelle
1
Fork
94
Merge medio
1h 2m
PR unite (30g)
25

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di MergeFi/frontend

Tutte le issue di MergeFi/frontend

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.