jackwener/OpenCLI · error · CommandExecutionError

mubu: ${path}: code=${data.code} ${data.message ?? ''}

Error message

mubu: ${path}: code=${data.code} ${data.message ?? ''}

What it means

mubuPost throws this CommandExecutionError when the Mubu HTTP API responds successfully at the transport level but reports a business-logic failure in its JSON envelope (data.code !== 0), and the code is not recognized as an auth failure (AuthRequiredError is thrown for that case instead). The message embeds the API endpoint path, the numeric error code, and the API's message so you can see which Mubu operation was rejected and why. It indicates the command you asked Mubu to execute failed server-side.

Source

Thrown at clis/mubu/utils.js:53

        xhr.onerror = () => resolve({ ok: false, status: 0, data: null, error: 'network error' });
        xhr.send(${JSON.stringify(JSON.stringify(body))});
      });
    })()
  `);

  if (!result || result.error === 'no token') {
    throw new AuthRequiredError(MUBU_DOMAIN, AUTH_HINT);
  }
  if (!result.ok || !result.data) {
    throw new CommandExecutionError(`mubu: ${path}: HTTP ${result.status} ${result.error ?? ''}`);
  }

  const { data } = result;
  if (data.code !== 0) {
    if (isAuthFailure(data.code, data.message)) {
      throw new AuthRequiredError(MUBU_DOMAIN, AUTH_HINT);
    }
    throw new CommandExecutionError(`mubu: ${path}: code=${data.code} ${data.message ?? ''}`);
  }

  return data.data;
}

export function formatDate(ts) {
  if (!ts) return '';
  const d = new Date(ts);
  const pad = (n) => String(n).padStart(2, '0');
  return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())} ${pad(d.getHours())}:${pad(d.getMinutes())}`;
}

const NAMED_ENTITIES = { amp: '&', lt: '<', gt: '>', quot: '"', apos: "'", nbsp: ' ' };

function decodeHtmlEntities(s) {
  return s
    .replace(/&#x([0-9a-f]+);/gi, (_, h) => String.fromCodePoint(parseInt(h, 16)))
    .replace(/&#(\d+);/g, (_, n) => String.fromCodePoint(parseInt(n, 10)))

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Read data.code and data.message in the error text and check them against the Mubu API response for the given path to identify the actual failure.
  2. Verify the document/outline ID passed to the command exists and is accessible to the authenticated account.
  3. If the code is auth-related (e.g. token expired), re-authenticate; consider extending isAuthFailure to cover the code you hit.
  4. Retry the request if the code indicates a transient server-side problem, after confirming parameters are correct.

Example fix

// before
text = 'my outline';
mubuPost('/api/xxx', { text });
// after
// confirm the target outline id is valid and owned by the account
const doc = await getOutline(knownValidId);
mubuPost('/api/xxx', { id: doc.id, text });
Defensive patterns

Strategy: try-catch

Validate before calling

if (!outlineId) throw new Error('refusing to call mubu: outlineId is empty');

Type guard

function isMubuEnvelope(d) { return d && typeof d === 'object' && typeof d.code === 'number'; }

Try / catch

try {
  const out = await mubuPost(path, payload);
} catch (e) {
  if (e instanceof AuthRequiredError) { await reauth(); }
  else if (/code=\d+/.test(e.message)) {
    const code = Number(e.message.match(/code=(\d+)/)[1]);
    if (TRANSIENT_CODES.has(code)) await retry();
    else console.error('Mubu rejected command:', e.message);
  } else throw e;
}

Prevention

When it happens

Trigger: Calling any Mubu command via mubuPost (e.g. creating or updating a document) where result.data.code is non-zero and isAuthFailure(data.code, data.message) is false; e.g. invalid document ID, permission denial, rate limit, or malformed parameters rejected by the Mubu API.

Common situations: Referencing a deleted or foreign-outline document ID; operating on a document the authenticated account cannot edit; passing bad parameters (wrong parentId, invalid content shape); Mubu API version drift introducing new error codes not covered by isAuthFailure; transient Mubu server errors surfaced as non-zero codes.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/5f3e664eab7bfd86. Report an issue: GitHub.