Skip to content

Bug Report — Two API Failures with SDK v0.1.1 #8

@shwetank-dev

Description

@shwetank-dev

Bug Report — Two API Failures with SDK v0.1.1

Date: 2026-02-18
SDK: @nimblebrain/mpak-sdk@0.1.1


Environment

Field Value
OS macOS Darwin 24.5.0 (ARM64 / Apple Silicon)
Machine Shwetanks-Mac-mini.local
Node.js v22.12.0
npm 10.9.0
SDK version @nimblebrain/mpak-sdk@0.1.1
Default registry https://api.mpak.dev

Bug 1 — searchBundles returns MpakNetworkError for HTTP 404 (wrong error class)

What the docs say should happen (README.md lines 28–33):

const results = await client.searchBundles({ q: 'mcp', limit: 10 });
// → returns an object with a `bundles` array
for (const bundle of results.bundles) {
  console.log(`${bundle.name}@${bundle.latest_version}`);
}

What actually happens:

MpakNetworkError: Failed to search bundles: HTTP 404
  code: 'NETWORK_ERROR'
  statusCode: undefined

Root cause (SDK source dist/index.js):

The searchBundles method hits GET /v1/bundles/search — the server returned HTTP 404, and the SDK catches any non-ok response and always throws MpakNetworkError:

if (!response.ok) {
  throw new MpakNetworkError(`Failed to search bundles: HTTP ${response.status}`);
}

Two problems here:

  1. Wrong error class. Per the README, MpakNetworkError is for "Network failures, timeouts". A 404 is a server-side logical error, not a network failure. The SDK uses MpakNotFoundError correctly in getBundle, but not in searchBundles.
  2. statusCode is always undefined on MpakNetworkError. The MpakNetworkError constructor signature is constructor(message) — it never sets statusCode, so callers can't programmatically inspect the HTTP status from the error object. The status is only embedded in the message string.

Bug 2 — getBundle('@nimblebraininc/echo') returns 404 / bundle not found

What the docs say should happen (README.md lines 38–42):

const bundle = await client.getBundle('@nimblebraininc/echo');
console.log(bundle.description);
console.log(`Versions: ${bundle.versions.map(v => v.version).join(', ')}`);

What actually happens:

MpakNotFoundError: Resource not found: @nimblebraininc/echo
  code: 'NOT_FOUND'
  statusCode: 404

The SDK itself documents @nimblebraininc/echo as the canonical example bundle in the README. The bundle either does not exist at GET /v1/bundles/@nimblebraininc/echo, or the scope/name has changed in the registry. This is a docs/registry inconsistency — the example bundle referenced in the SDK's own README cannot be fetched.


Summary Table

# Method Expected Actual Error Type
1 searchBundles({ q: 'mcp', limit: 10 }) { bundles: [...] } Throws on HTTP 404 from /v1/bundles/search MpakNetworkError (should be MpakNotFoundError or empty result)
2 getBundle('@nimblebraininc/echo') Bundle object with description, versions[] Bundle does not exist in registry MpakNotFoundError — README example is stale

Steps to Reproduce

1. Create a new directory and initialise a project

mkdir mpak-bug-repro
cd mpak-bug-repro
npm init -y

2. Install the SDK

npm install @nimblebrain/mpak-sdk

3. Create the test file

Create a file named test.mjs with the following content:

import { MpakClient } from '@nimblebrain/mpak-sdk';

const client = new MpakClient();

async function main() {
  // Searching for bundles
  try {
    const results = await client.searchBundles({ q: 'mcp', limit: 10 });

    for (const bundle of results.bundles) {
      console.log(`${bundle.name}@${bundle.latest_version}`);
    }
  } catch (err) {
    console.log('Error while fetching bundles', err);
  }

  // Fetching echo bundle
  try {
    const bundle = await client.getBundle('@nimblebraininc/echo');
    console.log(bundle.description);
    console.log(
      `Versions: ${bundle.versions.map((v) => v.version).join(', ')}`,
    );
  } catch (err) {
    console.log('Error while fetching echo bundle', err);
  }
}

main();

4. Run the file

node test.mjs

5. Observe the output

Error while fetching bundles MpakNetworkError: Failed to search bundles: HTTP 404
    at MpakClient.searchBundles (.../node_modules/@nimblebrain/mpak-sdk/dist/index.js:68:13)
    ...
    code: 'NETWORK_ERROR',
    statusCode: undefined

Error while fetching echo bundle MpakNotFoundError: Resource not found: @nimblebraininc/echo
    at MpakClient.getBundle (.../node_modules/@nimblebrain/mpak-sdk/dist/index.js:80:13)
    ...
    code: 'NOT_FOUND',
    statusCode: 404

Bug report generated with the help of Claude Code (claude-sonnet-4-6).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions