jackwener/OpenCLI · error · CliError
EMPTY_RESPONSE
EMPTY_RESPONSE
Error message
EMPTY_RESPONSE
What it means
The yollomi remove-bg command throws EMPTY_RESPONSE when /api/ai/remove-bg returns no processed image. The check on data.image / data.images[0] fails when the endpoint yields no output, aborting before download.
Source
Thrown at clis/yollomi/remove-bg.js:27
cli({
site: 'yollomi',
name: 'remove-bg',
access: 'write',
description: 'Remove image background with AI (free)',
domain: YOLLOMI_DOMAIN,
strategy: Strategy.COOKIE,
args: [
{ name: 'image', positional: true, required: true, help: 'Image URL to remove background from' },
{ 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) => {
log.status('Removing background...');
const data = await yollomiPost(page, '/api/ai/remove-bg', { imageUrl: kwargs.image });
const url = data.image || (data.images?.[0]);
if (!url)
throw new CliError('EMPTY_RESPONSE', 'No result', 'Check the input image URL');
if (kwargs['no-download'])
return [{ status: 'processed', file: '-', size: '-', url }];
try {
const filename = `yollomi_nobg_${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
- Check the input image URL is public and valid (per the hint)
- Pass an accessible URL, not a local path — upload first if needed (`yollomi upload`)
- Retry in case of a transient server-side failure
- Log the raw response to detect swallowed error fields
- Update extraction logic if the API response schema changed
Example fix
// before opencli yollomi remove-bg --image ./photo.jpg // after opencli yollomi upload ./photo.jpg # returns hosted URL opencli yollomi remove-bg --image https://.../photo.jpg
Defensive patterns
Strategy: validation
Validate before calling
if (!/^https?:\/\//.test(kwargs.image)) throw new Error('remove-bg requires a public URL, not a local path — upload the file first');
const ok = await fetch(kwargs.image, { method: 'HEAD' });
if (!ok.ok) throw new Error(`image URL not reachable: ${ok.status}`); Type guard
function hasBgRemovedImage(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['remove-bg']({ image: url });
} catch (e) {
if (e.code === 'EMPTY_RESPONSE') {
// local path passed in? upload first, then retry once
console.error(`${e.message}: ${e.hint}`);
} else throw e;
} Prevention
- Always pass a hosted URL, not a local file path (use `yollomi upload` first)
- HEAD-check the URL for 200 before invoking
- Use images with a clearly separable subject
- Catch EMPTY_RESPONSE and distinguish 'bad URL' from transient failure
When it happens
Trigger: POSTing { imageUrl: kwargs.image } where the URL cannot be fetched or processed server-side, the image has no clear subject, or the response schema no longer uses image/images fields.
Common situations: Passing a local file path instead of a URL for --image; URL behind login/expired signed link; input image corrupt or unsupported format; site API response change.
Related errors
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/c72012acca0a0e99.
Report an issue: GitHub.