Skip to content

fix(web): normalize backend API URL and accept legacy search response…#201

Closed
madmansn0w wants to merge 1 commit into
abhigyanpatwari:mainfrom
madmansn0w:codex/fix-backend-api-url-normalization-clean
Closed

fix(web): normalize backend API URL and accept legacy search response…#201
madmansn0w wants to merge 1 commit into
abhigyanpatwari:mainfrom
madmansn0w:codex/fix-backend-api-url-normalization-clean

Conversation

@madmansn0w

Copy link
Copy Markdown

Summary

Fix backend-mode agent failures in gitnexus-web caused by API URL and response-shape mismatches.

What this fixes

  1. Double /api path bug

    • Backend base URL can already be normalized to .../api.
    • Worker previously appended /api/... again, producing .../api/api/query and .../api/api/search.
    • This caused backend queries/search to fail and the assistant to report empty codebase stats.
  2. Legacy /api/search response compatibility

    • Some backend responses are flat arrays ({ results: [...] }) instead of grouped shape (process_symbols, definitions).
    • Worker now supports both formats so search results are not dropped to empty.

File changed

  • gitnexus-web/src/workers/ingestion.worker.ts

Validation

  • Reproduced backend endpoints for indexed repos (crank, crank-control, mentat) and confirmed non-empty graph/query results.
  • Built frontend successfully (npm run build in gitnexus-web).
  • Verified URL normalization logic returns correct endpoints for both:
    • http://localhost:4747
    • http://localhost:4747/api

Impact

  • Localized change in backend HTTP wrappers used by backend-mode agent init/query/search.
  • No schema or API contract changes.

@vercel

vercel Bot commented Mar 6, 2026

Copy link
Copy Markdown

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

A member of the Team first needs to authorize it.

@reversTeam reversTeam left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small and focused fix. The buildBackendApiUrl helper correctly normalizes the backend URL regardless of whether the user provides http://host:3000 or http://host:3000/api.

The logic is straightforward:

  1. Strip trailing slashes from the base URL.
  2. Ensure the endpoint path starts with /.
  3. If the base already ends with /api, append the path directly; otherwise, insert /api.

This prevents the /api/api/... double-prefix issue that would occur when users configure a URL already containing the /api segment.

Note: This diff is a subset of #202 (which includes additional changes). If #202 lands first, this PR may become redundant or conflict-free. Worth coordinating the merge order.

LGTM.

@madmansn0w

Copy link
Copy Markdown
Author

Addressed in #202 - thanks for catching that.

@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.

3 participants