abhigyanpatwari/GitNexus · error

Failed to start embedding generation

Error message

Failed to start embedding generation

What it means

HTTP 500 returned by POST /api/embed's outer catch when route setup throws anything other than an 'already in progress' conflict (the repo-lock case is answered 409 earlier in the handler flow). err.message is forwarded when present; the literal 'Failed to start embedding generation' appears only for an anonymous error with an empty message. The underlying failure is visible in the serve logs.

Solutions

  1. Check the serve console for the real error — the 500 body is intentionally unhelpful
  2. Verify the repo resolves (GET /api/repos) and is not locked by a running analyze (that case returns 409, not 500)
  3. Retry once after any active job settles
  4. If reproducible, update GitNexus and report — a 500 on this route is a server defect

Example fix

// before
const { jobId } = await res.json(); // throws on 500

// after
if (res.status === 409) { /* adopt/poll the active job */ }
else if (res.status >= 500) { await backoffRetry(() => postEmbed(repoName), 2); }
else if (!res.ok) throw new Error((await res.json()).error);
Defensive patterns

Strategy: retry

Try / catch

Mirror the analyze route pattern: 409 → adopt/poll the active job; 5xx → retry the idempotent embed POST with backoff; 4xx → surface the forwarded error text.

Prevention

When it happens

Trigger: Unexpected throws during embed job creation or route setup — storage or environment problems that make an early step throw; GitNexus bugs; error objects lacking messages reaching the catch.

Common situations: Disk-full or read-only storage breaking job setup; version skew after upgrades; rare crashes reported with no forwarded message — the literal fallback text is the tell.

Related errors


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

Appendix: source

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

            const current = embedJobManager.getJob(job.id);
            if (!current || current.status !== 'failed') {
              embedJobManager.updateJob(job.id, {
                status: 'failed',
                error: err.message || 'Embedding generation failed',
              });
            }
          } finally {
            clearTimeout(embedTimeout);
            releaseRepoLock(repoLockPath);
          }
        })();

        res.status(202).json({ jobId: job.id, status: 'analyzing' });
      } catch (err: any) {
        if (err.message?.includes('already in progress')) {
          res.status(409).json({ error: err.message });
        } else {
          res.status(500).json({ error: err.message || 'Failed to start embedding generation' });
        }
      }
    },
  );

  // GET /api/embed/:jobId — poll embedding job status
  app.get('/api/embed/:jobId', (req, res) => {
    const job = embedJobManager.getJob(req.params.jobId);
    if (!job) {
      res.status(404).json({ error: 'Job not found' });
      return;
    }
    res.json({
      id: job.id,
      status: job.status,
      repoName: job.repoName,
      progress: job.progress,
      error: job.error,

View on GitHub (pinned to 0d1aed942f)