jackwener/OpenCLI · error · CliError
EMPTY_RESPONSE
EMPTY_RESPONSE
Error message
EMPTY_RESPONSE
What it means
The yollomi background-removal command throws EMPTY_RESPONSE when the API response contains no usable result image. After yollomiPost returns, the code checks data.image or data.images[0]; if neither exists, no image was produced. This guards against saving/downloading an undefined URL.
Source
Thrown at clis/yollomi/background.js:34
args: [
{ name: 'image', positional: true, required: true, help: 'Image URL (upload via "opencli yollomi upload" first)' },
{ name: 'prompt', default: '', help: 'Background description (optional)' },
{ name: 'output', default: './yollomi-output', help: 'Output directory' },
{ name: 'no-download', type: 'boolean', default: false, help: 'Only show URL' },
],
columns: ['status', 'file', 'size', 'url'],
func: async (page, kwargs) => {
const imageUrl = kwargs.image;
const prompt = kwargs.prompt;
log.status('Generating background...');
const data = await yollomiPost(page, '/api/ai/ai-background-generator', {
images: [imageUrl],
prompt: prompt || undefined,
aspect_ratio: '1:1',
});
const url = data.image || (data.images?.[0]);
if (!url)
throw new CliError('EMPTY_RESPONSE', 'No result', 'Try a different image');
if (kwargs['no-download'])
return [{ status: 'generated', file: '-', size: '-', url }];
try {
const filename = `yollomi_bg_${Date.now()}.png`;
const { path: fp, size } = await downloadOutput(url, kwargs.output, filename);
return [{ status: 'saved', file: path.relative('.', fp), size: fmtBytes(size), url }];
}
catch {
return [{ status: 'download-failed', file: '-', size: '-', url }];
}
},
});
View on GitHub (pinned to 49907e53dc)
Solutions
- Print the raw response from yollomiPost to inspect what the API actually returned
- Retry the command — transient upstream failures often return empty bodies
- Verify the input image URL is publicly reachable and a supported format
- Check account credits / login state on the yollomi site
- Re-check the API response shape if the site was updated and fix the extraction (data.image vs data.images[0])
Example fix
// before
const url = data.image || (data.images?.[0]);
if (!url) throw new CliError('EMPTY_RESPONSE', 'No result', 'Try a different image');
// after
log.debug('raw response:', JSON.stringify(data));
const url = data.image || data.url || (data.images?.[0] ?? data.result?.[0]);
if (!url) throw new CliError('EMPTY_RESPONSE', 'No result', 'Try a different image'); Defensive patterns
Strategy: try-catch
Validate before calling
const url = kwargs.image;
if (!/^https?:\/\//.test(url)) throw new Error('image must be a public URL');
const ok = await fetch(url, { method: 'HEAD' });
if (!ok.ok) throw new Error(`image URL not reachable: ${ok.status}`); Type guard
function hasImage(d) {
return d != null && (typeof d.image === 'string' || (Array.isArray(d.images) && typeof d.images[0] === 'string'));
} Try / catch
try {
const rows = await opencli.yollomi.background({ image: url });
} catch (e) {
if (e.code === 'EMPTY_RESPONSE') {
// verify image URL is public/valid, retry once, then surface e.hint
console.error(`No result from yollomi: ${e.message} — ${e.hint}`);
} else throw e;
} Prevention
- Always pass publicly reachable image URLs, never local paths or auth-walled links
- HEAD-check the image URL before invoking
- Handle EMPTY_RESPONSE distinctly from network errors and use e.hint for remediation
- Log full response bodies in debug mode to catch schema drift early
When it happens
Trigger: Calling the background command when the yollomi site's /api/ai/remove-bg-style endpoint returns 200 with a JSON body lacking both `image` and `images` (e.g. API changed shape, silent upstream failure, or the request payload `{ images: [imageUrl], prompt, aspect_ratio: '1:1' }` was rejected without an error field).
Common situations: The site changed its response schema; the input image URL is private/blocked so generation silently yields nothing; credits exhausted but API returns empty body; transient server-side failure swallowed by the scraping layer.
Related errors
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/3e3389f2e40d9c56.
Report an issue: GitHub.