Skip to content

fix(client): prefix all routes with /api/ — every SDK call was 404ing#2

Merged
darkfordays merged 4 commits into
mainfrom
fix/api-prefix-paths
May 29, 2026
Merged

fix(client): prefix all routes with /api/ — every SDK call was 404ing#2
darkfordays merged 4 commits into
mainfrom
fix/api-prefix-paths

Conversation

@darkfordays
Copy link
Copy Markdown
Contributor

TL;DR

Every SDK call has been returning HTTP 404 for ~7 weeks. The backend migrated all routers to live under /api/* (except the bare /health probe), but kovamind/client.py still calls /memory/extract, /vault/v2/setup, etc. without the /api prefix.

Verified live against the staging backend on 2026-05-28:

  • POST https://api.kovamind.io/memory/extract -> HTTP 404
  • POST https://api.kovamind.io/api/memory/extract -> HTTP 200 (or 401 if auth missing)

This is the same systemic bug class as KovaMind/Kova-Mind PRs #612 + #614 (deploy webhook URL fix). The /api/* migration on the backend never propagated to the public SDKs.

Change

One file: kovamind/client.py. 14 path strings get /api/ prepended. /health stays bare. No behavior change beyond the URL fix.

- self._post("/memory/extract", payload)
+ self._post("/api/memory/extract", payload)
... (13 more identical-shape changes for /memory/* and /vault/v2/* paths)
- self._get("/health", {})  # stays bare — backend exempts /health from /api/

Plus a patch-version bump in pyproject.toml.

Why patch the path strings, not the base URL?

KovaMind(api_key=..., base_url="https://my-self-hosted.example.com") should still work for self-hosters. The base URL is the HOST; the /api is a path namespace within the host. Self-hosters mirror our path layout, so prepending /api to each call keeps the override semantics clean.

Tests

Existing tests at tests/test_client.py mock HTTP at the requests-session level, so they pass without hitting a real server — and they didn't catch this bug. That's a separate followup (the tests should at minimum assert what URL the mock saw). For THIS PR I'm fixing the live bug, not refactoring tests.

Verification plan post-merge

  1. Bump the patch version (done in this PR)
  2. Publish to PyPI
  3. pip install kovamind in a fresh venv, run the README quickstart against a real km_live_/km_test_ key, expect non-404 results

Closes the "SDK broken in production" gap surfaced during the 2026-05-28 cross-repo audit.

Backend mounts every router under the /api/* namespace (except the bare
/health probe). Pre-fix the SDK was calling /memory/extract, /vault/v2/setup,
etc. directly — every one of those returns HTTP 404 against the live
api.kovamind.io.

Patched 14 path strings:
  /memory/extract -> /api/memory/extract
  /memory/retrieve -> /api/memory/retrieve
  /memory/reinforce -> /api/memory/reinforce
  /memory/surprise -> /api/memory/surprise
  /memory/context -> /api/memory/context
  /vault/v2/setup -> /api/vault/v2/setup
  /vault/v2/unlock -> /api/vault/v2/unlock
  /vault/v2/lock -> /api/vault/v2/lock
  /vault/v2/credentials (POST) -> /api/vault/v2/credentials
  /vault/v2/credentials (GET)  -> /api/vault/v2/credentials
  /vault/v2/handles -> /api/vault/v2/handles
  /vault/v2/find -> /api/vault/v2/find
  /vault/v2/execute -> /api/vault/v2/execute
  /vault/v2/recover -> /api/vault/v2/recover

/health stays bare (intentional — backend exempts it from /api).

Same systemic bug class as KovaMind/Kova-Mind PRs #612 + #614 (deploy
webhook URL fix). The /api/* migration on the backend never propagated
to the public SDKs. Verified live against staging on 2026-05-28: paths
without /api return 404, paths with /api return 401 (auth) or 200 (with
valid bearer token).
Copilot AI review requested due to automatic review settings May 28, 2026 06:38
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes a production-down bug where every SDK call was returning HTTP 404 because the backend migrated all routers under /api/* (with /health exempt) but kovamind/client.py was still hitting the bare paths. The fix prepends /api/ to each affected route string and bumps the package version, leaving base_url semantics intact so self-hosters can keep overriding the host.

Changes:

  • Prefix all memory and vault v2 route strings in kovamind/client.py with /api/, keeping /health bare.
  • Bump project version from 0.5.1 to 0.5.2 in pyproject.toml.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
kovamind/client.py Prepends /api/ to memory and vault v2 endpoints to match the backend's routing migration.
pyproject.toml Patch-version bump to 0.5.2 for the bugfix release.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pyproject.toml
Comment thread kovamind/client.py
@darkfordays darkfordays merged commit 5bb2442 into main May 29, 2026
0 of 4 checks passed
@darkfordays darkfordays deleted the fix/api-prefix-paths branch May 29, 2026 03:21
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.

2 participants