{"record":{"id":"3e3389f2e40d9c56","repo":"jackwener/OpenCLI","slug":"empty-response","errorCode":"EMPTY_RESPONSE","errorMessage":"EMPTY_RESPONSE","messagePattern":"EMPTY_RESPONSE","errorType":"error_code","errorClass":"CliError","httpStatus":null,"severity":"error","filePath":"clis/yollomi/background.js","lineNumber":34,"sourceCode":"    args: [\n        { name: 'image', positional: true, required: true, help: 'Image URL (upload via \"opencli yollomi upload\" first)' },\n        { name: 'prompt', default: '', help: 'Background description (optional)' },\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        const imageUrl = kwargs.image;\n        const prompt = kwargs.prompt;\n        log.status('Generating background...');\n        const data = await yollomiPost(page, '/api/ai/ai-background-generator', {\n            images: [imageUrl],\n            prompt: prompt || undefined,\n            aspect_ratio: '1:1',\n        });\n        const url = data.image || (data.images?.[0]);\n        if (!url)\n            throw new CliError('EMPTY_RESPONSE', 'No result', 'Try a different image');\n        if (kwargs['no-download'])\n            return [{ status: 'generated', file: '-', size: '-', url }];\n        try {\n            const filename = `yollomi_bg_${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":16,"sourceCodeEnd":47,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/yollomi/background.js#L16-L47","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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])"],"exampleFix":"// before\nconst url = data.image || (data.images?.[0]);\nif (!url) throw new CliError('EMPTY_RESPONSE', 'No result', 'Try a different image');\n// after\nlog.debug('raw response:', JSON.stringify(data));\nconst url = data.image || data.url || (data.images?.[0] ?? data.result?.[0]);\nif (!url) throw new CliError('EMPTY_RESPONSE', 'No result', 'Try a different image');","handlingStrategy":"try-catch","validationCode":"const url = kwargs.image;\nif (!/^https?:\\/\\//.test(url)) throw new Error('image must be a public URL');\nconst ok = await fetch(url, { method: 'HEAD' });\nif (!ok.ok) throw new Error(`image URL not reachable: ${ok.status}`);","typeGuard":"function hasImage(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.background({ image: url });\n} catch (e) {\n  if (e.code === 'EMPTY_RESPONSE') {\n    // verify image URL is public/valid, retry once, then surface e.hint\n    console.error(`No result from yollomi: ${e.message} — ${e.hint}`);\n  } else throw e;\n}","preventionTips":["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"],"tags":["empty-response","api","cli","image-generation"],"backgroundTag":"empty-api-response","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}