jackwener/OpenCLI · error · CliError

EMPTY_RESPONSE

EMPTY_RESPONSE

Error message

EMPTY_RESPONSE

What it means

The yollomi try-on command throws EMPTY_RESPONSE when the virtual try-on endpoint returns no generated image. The code checks data.image then data.images[0]; if neither exists, no try-on result was produced and the command aborts.

Source

Thrown at clis/yollomi/try-on.js:35

        { name: 'person', required: true, help: 'Person photo URL (upload via "opencli yollomi upload" first)' },
        { name: 'cloth', required: true, help: 'Clothing image URL' },
        { name: 'cloth-type', default: 'upper', choices: ['upper', 'lower', 'overall'], help: 'Clothing type' },
        { 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('Processing virtual try-on...');
        const data = await yollomiPost(page, '/api/ai/virtual-try-on', {
            person_image: kwargs.person,
            cloth_image: kwargs.cloth,
            cloth_type: kwargs['cloth-type'],
            output_format: 'png',
            output_quality: 100,
        });
        const url = data.image || (data.images?.[0]);
        if (!url)
            throw new CliError('EMPTY_RESPONSE', 'No result', 'Check both images have clear subjects');
        if (kwargs['no-download'])
            return [{ status: 'generated', file: '-', size: '-', url }];
        try {
            const filename = `yollomi_tryon_${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

  1. Use images with clear, unoccluded subjects (per the hint)
  2. Verify --cloth-type matches a supported value (e.g. upper/lower/overall)
  3. Ensure both image URLs are publicly accessible and valid formats
  4. Log the raw response to check for swallowed error fields
  5. Update extraction logic if the API response schema changed

Example fix

// before
const url = data.image || (data.images?.[0]);
if (!url) throw new CliError('EMPTY_RESPONSE', 'No result', 'Check both images have clear subjects');
// after
if (data.error) throw new CliError('API_ERROR', data.error, 'Check try-on API response');
const url = data.image || data.output || (data.images?.[0]);
if (!url) throw new CliError('EMPTY_RESPONSE', 'No result', 'Check both images have clear subjects');
Defensive patterns

Strategy: validation

Validate before calling

const CLOTH_TYPES = ['upper', 'lower', 'overall' /* verify via docs/models list */];
if (!CLOTH_TYPES.includes(kwargs['cloth-type'])) throw new Error(`unsupported cloth-type: ${kwargs['cloth-type']}`);
for (const u of [kwargs.person, kwargs.cloth]) if (!(await fetch(u, { method: 'HEAD' })).ok) throw new Error(`image not reachable: ${u}`);

Type guard

function hasTryOnImage(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['try-on']({ person, cloth, 'cloth-type': 'upper' });
} catch (e) {
  if (e.code === 'EMPTY_RESPONSE') {
    console.error(`${e.message}: ${e.hint} — use clear, unoccluded subject photos`);
  } else throw e;
}

Prevention

When it happens

Trigger: POSTing the person/garment image pair with cloth_type, output_format 'png', output_quality 100 yields a 200 body without image fields — images unreadable server-side, unsupported cloth_type, or schema change.

Common situations: Garment image with cluttered background so no clear subject detected; person image where clothing is occluded; --cloth-type value not accepted by the endpoint; expired/unfetchable image URLs.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/3bddb5a8b59b81b0. Report an issue: GitHub.