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
- Retry later — API-level 5xx is often transient
- Simplify or correct the query string and re-run
- Open the same query in a browser to read result.status.text for the exact API error
- 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
- Read result.status.text (surfaced in the error) for the exact API failure
- Retry 5xx API statuses with backoff; fix the query for 4xx
- Test the exact query in a browser to confirm what dblp accepts
- Keep queries simple and URL-encoded
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
- ${label} returned HTTP ${res.status}
- ${label} returned HTTP ${resp.status}: ${summarizeApiError(p
- archive search failed: HTTP ${resp.status}
- HTTP ${result.httpStatus} from /api/organizations
- coingecko derivatives returned HTTP ${resp.status}
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/59e5d44c6a56fb1c.
Report an issue: GitHub.