{"record":{"id":"3b7ba416ccadd0ae","repo":"jackwener/OpenCLI","slug":"empty-response-3b7ba4","errorCode":"EMPTY_RESPONSE","errorMessage":"EMPTY_RESPONSE","messagePattern":"EMPTY_RESPONSE","errorType":"error_code","errorClass":"CliError","httpStatus":null,"severity":"error","filePath":"clis/yollomi/face-swap.js","lineNumber":32,"sourceCode":"    description: 'Swap faces between two photos (3 credits)',\n    domain: YOLLOMI_DOMAIN,\n    strategy: Strategy.COOKIE,\n    args: [\n        { name: 'source', required: true, help: 'Source face image URL' },\n        { name: 'target', required: true, help: 'Target photo URL' },\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('Swapping faces...');\n        const data = await yollomiPost(page, '/api/ai/face-swap', {\n            swap_image: kwargs.source,\n            input_image: kwargs.target,\n        });\n        const url = data.image || (data.images?.[0]);\n        if (!url)\n            throw new CliError('EMPTY_RESPONSE', 'No result', 'Make sure both images contain clear faces');\n        if (kwargs['no-download'])\n            return [{ status: 'swapped', file: '-', size: '-', url }];\n        try {\n            const filename = `yollomi_faceswap_${Date.now()}.jpg`;\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":14,"sourceCodeEnd":45,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/yollomi/face-swap.js#L14-L45","documentation":"The yollomi face-swap command throws EMPTY_RESPONSE when /api/ai/face-swap returns no image. The code checks data.image then data.images[0]; absence of both means the swap produced no output, so it aborts rather than downloading an undefined URL.","triggerScenarios":"POSTing { swap_image, input_image } to /api/ai/face-swap yields a 200 response without image fields — typically one of the two images has no detectable face, an image failed to fetch server-side, or the schema changed.","commonSituations":"Input photos where faces are too small, occluded, or non-frontal; swapped source/target arguments by mistake; images behind auth walls the server cannot fetch; site API update.","solutions":["Retry with clearer, front-facing photos in both images (per the hint)","Verify you did not swap `--source` and `--target` arguments","Ensure both image URLs/files are publicly accessible and valid formats","Log the raw API response to check for ignored error fields","Re-check response field names if the site API was updated"],"exampleFix":"// before\nconst url = data.image || (data.images?.[0]);\nif (!url) throw new CliError('EMPTY_RESPONSE', 'No result', 'Make sure both images contain clear faces');\n// after\nif (data.error) throw new CliError('API_ERROR', data.error, 'Check face-swap API response');\nconst url = data.image || data.output || (data.images?.[0]);\nif (!url) throw new CliError('EMPTY_RESPONSE', 'No result', 'Make sure both images contain clear faces');","handlingStrategy":"validation","validationCode":"for (const u of [source, target]) {\n  const res = await fetch(u, { method: 'HEAD' });\n  if (!res.ok) throw new Error(`image not reachable: ${u}`);\n}","typeGuard":"function hasSwappedImage(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['face-swap']({ source, target });\n} catch (e) {\n  if (e.code === 'EMPTY_RESPONSE') {\n    console.error(`Face swap failed: ${e.hint} — check --source/--target order and photo quality`);\n  } else throw e;\n}","preventionTips":["Use front-facing, unoccluded face photos for both inputs","Double-check --source (swap image) vs --target (base image) order","HEAD-check both image URLs first","Retry once on EMPTY_RESPONSE before giving up"],"tags":["empty-response","api","cli","face-swap"],"backgroundTag":"empty-api-response","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}