jackwener/OpenCLI · error · CommandExecutionError
${label} returned JSON without result.status.@code
Error message
${label} returned JSON without result.status.@code What it means
Thrown by dblpFetchJson when the parsed JSON body lacks result.status.@code — dblp's JSON envelope is missing the expected API status field. This guards against dblp changing its response schema or returning a partial/error payload that is still valid JSON.
Source
Thrown at clis/dblp/utils.js:66
throw new EmptyResultError(label, 'dblp returned 404 — the requested record may not exist.');
}
throw new CommandExecutionError(`${label} returned HTTP ${res.status}`, 'Inspect the response in a browser at the same URL for more context.');
}
return res;
}
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();
}View on GitHub (pinned to 49907e53dc)
Solutions
- Inspect the raw JSON in a browser at the same URL to see the actual shape
- Retry later in case dblp served a partial response
- Verify the request path uses the documented /search/.../api?q=...&format=json form
- If dblp changed its envelope, update the parsing code to the new schema
Example fix
// before
const json = await dblpFetchJson(path, 'dblp search');
// after — guard at the call site
const json = await dblpFetchJson(path, 'dblp search');
if (!json?.result?.status) console.warn('Unexpected dblp envelope, raw:', JSON.stringify(json).slice(0, 200)); Defensive patterns
Strategy: type-guard
Validate before calling
const body = await res.json();
if (!body?.result?.status?.['@code']) {
console.warn('Unexpected dblp envelope:', JSON.stringify(body).slice(0, 200));
} Type guard
function hasDblpEnvelope(body) {
return !!body && typeof body === 'object'
&& !!body.result && typeof body.result === 'object'
&& !!body.result.status && typeof body.result.status === 'object'
&& typeof body.result.status['@code'] === 'string';
} Try / catch
try {
const json = await dblpFetchJson(path, 'dblp search');
} catch (err) {
if (/without result\.status/.test(err.message)) {
// dblp envelope changed or partial payload — dump the raw body and stop
console.error(err.message, err.details ?? '');
return null;
}
throw err;
} Prevention
- Validate the envelope shape before reading fields
- When dblp announces API changes, re-check the envelope schema
- Inspect raw responses in a browser when shapes look off
- Keep a fallback parser for alternate dblp JSON shapes
When it happens
Trigger: res.json() parses successfully but body.result.status['@code'] is undefined/empty — e.g. the endpoint returned a different JSON shape (error payload, HTML-to-JSON, or a changed API envelope).
Common situations: dblp API schema changes; requesting a path that returns a different JSON structure than the search API; intermediate proxies returning their own JSON error bodies with 200.
Related errors
- PARSE_ERROR
- 12306 ${endpoint} returned an unexpected payload shape
- ${label} returned an unexpected payload shape; expected an o
- archive snapshots returned malformed CDX payload: top-level
- archive snapshots returned malformed CDX payload: header row
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/7a1b609f877eea5b.
Report an issue: GitHub.