abhigyanpatwari/GitNexus · error

Repository not found

Error message

Repository not found

What it means

HTTP 404 from POST /api/query when resolveRepo(requestedRepo(req)) returns undefined — no repository could be resolved for the request. Resolution uses the ?repo= parameter when supplied, otherwise the server's default repo. A repository becomes resolvable only after gitnexus analyze has registered it; this 404 fires before any Cypher is executed.

Source

Thrown at gitnexus/src/server/api.ts:664

  resolveRepo: (repoName?: string) => Promise<{ storagePath: string } | undefined>,
): Promise<void> => {
  try {
    const cypher = req.body.cypher as string;
    if (!cypher) {
      res.status(400).json({ error: 'Missing "cypher" in request body' });
      return;
    }
    const queryParams = req.body.params;
    if (queryParams !== undefined && !isValidQueryParams(queryParams)) {
      res.status(400).json({
        error: '"params" must be a plain object with scalar values (string/number/boolean/null)',
      });
      return;
    }

    const entry = await resolveRepo(requestedRepo(req));
    if (!entry) {
      res.status(404).json({ error: 'Repository not found' });
      return;
    }
    const lbugPath = path.join(entry.storagePath, 'lbug');
    const result = await withLbugDb(lbugPath, () => executePrepared(cypher, queryParams ?? {}), {
      readOnly: true,
    });
    res.json({ result });
  } catch (err: any) {
    if (isReadOnlyDbError(err)) {
      res.status(403).json({ error: 'Write queries are not allowed via the HTTP API' });
      return;
    }
    res.status(500).json({ error: err.message || 'Query failed' });
  }
};

/**
 * Validate the optional `token` field of POST /api/analyze. Returns an

View on GitHub (pinned to aac7515d2a)

Solutions

  1. Run `gitnexus analyze` in the repository so it is registered, then retry
  2. List what is actually available via GET /api/repos and use the exact registered name in ?repo=
  3. If you intended the default repo, start serve from the repo root (or pass the repo explicitly) so default resolution matches
  4. For upload-based repos, wait until the analysis job completes — the repo resolves only once registered
Defensive patterns

Strategy: validation

Validate before calling

// Resolve the repo name against the registry before querying.
const reposRes = await fetch(`${base}/api/repos`);
const repos: { name: string }[] = await reposRes.json();
const match = repos.find((r) => r.name === requestedName);
if (!match) throw new Error(`repo not registered — run gitnexus analyze. Available: ${repos.map((r) => r.name).join(', ')}`);

Try / catch

const res = await postQuery(cypher, requestedName);
if (res.status === 404 && (await res.json()).error === 'Repository not found') {
  const choices = await listRepos();
  promptRepoSelection(choices); // or trigger analyze in a guided flow
}

Prevention

When it happens

Trigger: POST /api/query with ?repo=typo or a name that differs from the registered name; no ?repo= given while the serve process was started from a directory whose repo was never indexed; querying right after wiping the index storage; the serve process defaulting to a different repo than the one you indexed.

Common situations: Fresh clone: developer starts gitnexus serve before running analyze; name mismatches (GitHub org prefix, .git suffix, case) between what the client sends and the registry entry; switching serve between repos and stale client ?repo= values; CI environments where the index lives in a different storage path.

Related errors


AI-assisted analysis of abhigyanpatwari/GitNexus@aac7515d2a (2026-08-20). Data as JSON: /api/errors/32517e757cb3b938. Report an issue: GitHub.