{"record":{"id":"c72012acca0a0e99","repo":"jackwener/OpenCLI","slug":"empty-response-c72012","errorCode":"EMPTY_RESPONSE","errorMessage":"EMPTY_RESPONSE","messagePattern":"EMPTY_RESPONSE","errorType":"error_code","errorClass":"CliError","httpStatus":null,"severity":"error","filePath":"clis/yollomi/remove-bg.js","lineNumber":27,"sourceCode":"cli({\n    site: 'yollomi',\n    name: 'remove-bg',\n    access: 'write',\n    description: 'Remove image background with AI (free)',\n    domain: YOLLOMI_DOMAIN,\n    strategy: Strategy.COOKIE,\n    args: [\n        { name: 'image', positional: true, required: true, help: 'Image URL to remove background from' },\n        { name: 'output', default: './yollomi-output', help: 'Output directory' },\n        { name: 'no-download', type: 'boolean', default: false, help: 'Only show URL' },\n    ],\n    columns: ['status', 'file', 'size', 'url'],\n    func: async (page, kwargs) => {\n        log.status('Removing background...');\n        const data = await yollomiPost(page, '/api/ai/remove-bg', { imageUrl: kwargs.image });\n        const url = data.image || (data.images?.[0]);\n        if (!url)\n            throw new CliError('EMPTY_RESPONSE', 'No result', 'Check the input image URL');\n        if (kwargs['no-download'])\n            return [{ status: 'processed', file: '-', size: '-', url }];\n        try {\n            const filename = `yollomi_nobg_${Date.now()}.png`;\n            const { path: fp, size } = await downloadOutput(url, kwargs.output, filename);\n            return [{ status: 'saved', file: path.relative('.', fp), size: fmtBytes(size), url }];\n        }\n        catch {\n            return [{ status: 'download-failed', file: '-', size: '-', url }];\n        }\n    },\n});\n","sourceCodeStart":9,"sourceCodeEnd":40,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/yollomi/remove-bg.js#L9-L40","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nopencli yollomi remove-bg --image ./photo.jpg\n// after\nopencli yollomi upload ./photo.jpg   # returns hosted URL\nopencli yollomi remove-bg --image https://.../photo.jpg","handlingStrategy":"validation","validationCode":"if (!/^https?:\\/\\//.test(kwargs.image)) throw new Error('remove-bg requires a public URL, not a local path — upload the file first');\nconst ok = await fetch(kwargs.image, { method: 'HEAD' });\nif (!ok.ok) throw new Error(`image URL not reachable: ${ok.status}`);","typeGuard":"function hasBgRemovedImage(d) {\n  return d != null && (typeof d.image === 'string' || (Array.isArray(d.images) && typeof d.images[0] === 'string'));\n}","tryCatchPattern":"try {\n  const rows = await opencli.yollomi['remove-bg']({ image: url });\n} catch (e) {\n  if (e.code === 'EMPTY_RESPONSE') {\n    // local path passed in? upload first, then retry once\n    console.error(`${e.message}: ${e.hint}`);\n  } else throw e;\n}","preventionTips":["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"],"tags":["empty-response","api","cli","background-removal"],"backgroundTag":"empty-api-response","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}