jackwener/OpenCLI · error · CommandExecutionError

${label} returned API status ${statusCode}${statusText ? ` (

Error message

${label} returned API status ${statusCode}${statusText ? ` (${statusText})` : ''}

What it means

Thrown when HTTP succeeded but dblp's JSON envelope reports an API-level status code other than 200 (with optional status text). dblp accepted the request but its own API layer rejected or failed the query.

Source

Thrown at clis/dblp/utils.js:73

export async function dblpFetchJson(path, label) {
    const res = await dblpFetch(`${DBLP_ORIGIN}${path}`, label, 'application/json');
    let body;
    try {
        body = await res.json();
    }
    catch (err) {
        throw new CommandExecutionError(`${label} returned malformed JSON: ${err?.message ?? err}`);
    }
    const statusCode = String(body?.result?.status?.['@code'] ?? '').trim();
    if (!statusCode) {
        throw new CommandExecutionError(
            `${label} returned JSON without result.status.@code`,
            'dblp changed its JSON envelope or returned a partial error payload; inspect the raw response in a browser.',
        );
    }
    if (statusCode !== '200') {
        const statusText = String(body?.result?.status?.text ?? '').trim();
        throw new CommandExecutionError(
            `${label} returned API status ${statusCode}${statusText ? ` (${statusText})` : ''}`,
            'dblp accepted the HTTP request but reported an API-level failure. Retry later or inspect the same query in a browser.',
        );
    }
    return body;
}

export async function dblpFetchXml(path, label) {
    const res = await dblpFetch(`${DBLP_ORIGIN}${path}`, label, 'application/xml');
    return res.text();
}

export function coerceInt(value) {
    if (value === undefined || value === null || value === '') return NaN;
    const n = typeof value === 'number' ? value : Number(value);
    return Number.isFinite(n) && Number.isInteger(n) ? n : NaN;
}

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Retry later — API-level 5xx is often transient
  2. Simplify or correct the query string and re-run
  3. Open the same query in a browser to read result.status.text for the exact API error
  4. Check dblp's search API FAQ for parameter changes

Example fix

// before
const q = '';
const json = await dblpFetchJson(`/search/publ/api?q=${q}&format=json`, 'dblp search'); // API status 400
// after
const q = 'database';
const json = await dblpFetchJson(`/search/publ/api?q=${encodeURIComponent(q)}&format=json`, 'dblp search');
Defensive patterns

Strategy: retry

Validate before calling

const q = encodeURIComponent(query.trim());
if (!q || q === '%20') throw new Error('Query must contain non-whitespace characters');

Type guard

function isApiOk(body) { return String(body?.result?.status?.['@code'] ?? '') === '200'; }

Try / catch

try {
  const json = await dblpFetchJson(path, 'dblp search');
} catch (err) {
  const m = /API status (\d+)/.exec(err.message);
  if (m && m[1].startsWith('5')) {
    await new Promise(r => setTimeout(r, 3000));
    return retryFetch(path); // API-side transient failure
  }
  if (m && m[1] === '400') {
    console.error('Query rejected by dblp — simplify the search terms');
    return null;
  }
  throw err;
}

Prevention

When it happens

Trigger: body.result.status['@code'] parses but !== '200' — e.g. dblp API returns status 400 for a bad query, 404 for unknown resources, or 5xx at the API layer.

Common situations: Malformed or unsupported search queries; dblp API-side incidents returning non-200 inside an HTTP-200 envelope; deprecated/changed query parameters.

Related errors


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