Skip to content

fix: surface server JSON error message on failed server connection#159

Closed
Asm3r96 wants to merge 1 commit into
abhigyanpatwari:mainfrom
Asm3r96:fix/server-connect-404-error-message
Closed

fix: surface server JSON error message on failed server connection#159
Asm3r96 wants to merge 1 commit into
abhigyanpatwari:mainfrom
Asm3r96:fix/server-connect-404-error-message

Conversation

@Asm3r96

@Asm3r96 Asm3r96 commented Mar 3, 2026

Copy link
Copy Markdown

Summary

Fixes #158

  • server-connection.ts: On non-ok responses, parse the JSON body and use body.error as the error message, falling back to HTTP status text if parsing fails.
  • api.ts: Expand the 404 error message to also hint at restarting the server after running gitnexus analyze.

Problem

When gitnexus serve has no indexed repo, GET /api/repo returns a 404 with a helpful JSON body but the client was discarding it, showing the user a cryptic Server returned 404: Not Found instead of the actionable message.

Result

User now sees: No repository indexed. Run gitnexus analyze in your project directory first, then restart the server.

When /api/repo returns 404 (no repo indexed), the server already sends
a helpful JSON body: { error: 'Repository not found. Run: gitnexus analyze' }
but fetchRepoInfo() was discarding it and only using the HTTP status text,
showing the user a cryptic "Server returned 404: Not Found" instead.

- server-connection.ts: parse JSON error body on non-ok responses and
  use body.error as the message, falling back to HTTP status text
- api.ts: expand the 404 message to also hint at restarting the server
  after running gitnexus analyze

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@vercel

vercel Bot commented Mar 3, 2026

Copy link
Copy Markdown

@Asm3r96 is attempting to deploy a commit to the NexusCore Team on Vercel.

A member of the Team first needs to authorize it.

@magyargergo

Copy link
Copy Markdown
Collaborator

⚠️ Upcoming Prettier formatting — rebase instructions

PR #563 adds Prettier as the code formatter for the repo. When it merges, the bulk format commit will touch ~350 files (style-only: whitespace, quotes, trailing commas). Your branch will likely conflict.

After #563 merges, rebase your branch:

git fetch origin
git checkout <your-branch>
git rebase origin/main

# Conflicts will be formatting-only — accept your version:
git checkout --theirs .
git add .
git rebase --continue

# Then re-format your branch to match the new style:
npx prettier --write .
git add -A
git commit -m "style: apply prettier formatting"
git push --force-with-lease

New setup step: Run npm install at the repo root (not just in gitnexus/) to get prettier + activate the pre-commit hook. The hook auto-formats staged files on every commit going forward.

@magyargergo

Copy link
Copy Markdown
Collaborator

Please submit a new PR if this is still relevant

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Server connect shows cryptic 404 error when no repo is indexed

2 participants