abhigyanpatwari/GitNexus · error
body
Error message
body
What it means
A generic 500 response: when a streaming response handler hits an error after headers may already have been sent, it tries a best-effort abort and otherwise returns `res.status(500).json(body)`. The `body` here is the pre-built error object describing why the request failed server-side.
Solutions
- Inspect the 500 body's error/message fields for the underlying cause
- Check GitNexus server logs around the request for the full stack trace
- Re-run `gitnexus analyze --index-only` if the index appears corrupted or stale
- Retry the request; if reproducible, report the stack trace as a bug
Example fix
// before: ignoring the 500 body
const res = await fetch(url); // 500
console.log(res.status);
// after: surface the server-provided cause
const res = await fetch(url);
if (!res.ok) console.error(await res.json()); // { error: '...' } Defensive patterns
Strategy: try-catch
Validate before calling
if (!res.ok && res.status === 500) {
const body = await res.json();
console.error('server error:', body.error ?? body);
} Try / catch
try {
const res = await fetch(streamUrl);
if (res.status === 500) {
const body = await res.json(); // error object carries the real cause
throw new Error(body.error ?? 'stream failed before start');
}
// ... consume stream
} catch (e) {
console.error(e); retryOrReport();
} Prevention
- Always parse the 500 body — it contains the server-side cause
- Keep the index fresh (`analyze --index-only`) to avoid corruption-driven failures
- Capture server logs when reproducing; report persistent 500s with the body
When it happens
Trigger: Any endpoint using this streaming error wrapper whose handler throws before streaming starts — e.g. an internal error while resolving the repo or preparing the streamed result — results in the 500 JSON body.
Common situations: Developers see this when the underlying query/search handler fails unexpectedly: corrupted index, failed repo resolution, or a bug in a handler that doesn't map its error to a specific status code.
Understand the failure class
Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.
Related errors
- -32000
- Cannot remove relationship
- content filter triggered mid-stream. The generated content…
- Failed to list repos
- Failed to read file
AI-assisted analysis of abhigyanpatwari/GitNexus@ac9a4e9abd (2026-09-15).
Data as JSON: /api/errors/72c952031f99756a.
Report an issue: GitHub.
Appendix: source
Thrown at gitnexus/src/server/api.ts:1378
readOnlyFtsOptions(skipFts),
);
res.json(graph);
} catch (err: any) {
if (sendStorageRequirementHttp(err, res)) return;
if (err instanceof ClientDisconnectedError) {
return;
}
const body = httpErrorBody(err, 'Failed to build graph');
if (res.headersSent) {
try {
res.write(JSON.stringify({ type: 'error', ...body }) + '\n');
} catch {
// Best-effort only after streaming has started.
}
res.end();
return;
}
res.status(500).json(body);
}
});
// Execute Cypher query
app.post('/api/query', async (req, res) => {
await handleQueryRequest(req, res, resolveRepo);
});
// Search (supports mode: 'hybrid' | 'semantic' | 'bm25', and optional enrichment)
app.post('/api/search', async (req, res) => {
try {
const query = (req.body.query ?? '').trim();
if (!query) {
res.status(400).json({ error: 'Missing "query" in request body' });
return;
}
const entry = await resolveRepo(requestedRepo(req));View on GitHub (pinned to ac9a4e9abd)