moeru-ai/airi · error · Error
Replicate returned an empty output array.
Error message
Replicate returned an empty output array.
What it means
Thrown when the output is an Array.isArray but items.length === 0. Replicate returned a structurally valid but empty output array — the prediction resolved with zero generated items. Sibling to [41] (null output) and [42] (unrecognizable item).
Source
Thrown at apps/stage-tamagotchi/src/main/services/airi/widgets/providers/replicate.ts:171
else if (typeof first === 'object' && first !== null && 'url' in first && typeof (first as any).url === 'string') {
imageUrl = (first as any).url
}
// Case 3: Simple string (the URL itself)
else if (typeof first === 'string') {
imageUrl = first
}
if (imageUrl && (imageUrl.startsWith('http') || imageUrl.startsWith('data:'))) {
log.log(`[Replicate] EXTRACTED IMAGE: ${imageUrl.startsWith('data:') ? 'DATA_URL' : imageUrl}`)
this.updateStatus(jobId, { status: 'succeeded', progress: 100, imageUrl })
}
else {
log.error(`[Replicate] Failed to extract URL from output: ${JSON.stringify(first)}`)
throw new Error('Output does not contain a recognizable image URL.')
}
}
else {
throw new Error('Replicate returned an empty output array.')
}
}
catch (error: any) {
const errorMessage = error.message || (typeof error === 'object' ? JSON.stringify(error) : String(error))
log.error(`[Replicate] Generation Failed for ${jobId}: ${errorMessage}`)
this.updateStatus(jobId, {
status: 'failed',
error: errorMessage,
actionLabel: `Error: ${errorMessage.slice(0, 50)}${errorMessage.length > 50 ? '...' : ''}`,
})
}
finally {
// Clean up callback and job result after completion to prevent memory leaks
setTimeout(() => {
this.callbacks.delete(jobId)
this.jobResults.delete(jobId)
}, 10000)
}View on GitHub (pinned to 27111382b4)
Solutions
- Retry with a different prompt to rule out a safety-filter block.
- Inspect request.extra and the merged inputOptions to ensure no option forces zero outputs (e.g. num_outputs: 0).
- Check the Replicate prediction page for the run to see if outputs were filtered.
- If persistent, switch models — some community models intermittently return empty arrays.
Defensive patterns
Strategy: retry
Type guard
function isNonEmptyOutputArray(output: unknown): output is unknown[] {
return Array.isArray(output) && output.length > 0
} Try / catch
try {
await provider.runGeneration(jobId, model, inputOptions)
} catch (e) {
if (e instanceof Error && e.message.includes('empty output array')) {
// retry once with a sanitized prompt
} else throw e
} Prevention
- Avoid prompts likely to trip safety filters.
- Ensure request.extra does not set num_outputs to 0.
- Retry once on empty-array outcomes.
When it happens
Trigger: An image model that normally returns multiple outputs returned none for this run; nsfw/safety filter blocked every output; model misconfigured with num_outputs=0 via extra options.
Common situations: Prompt tripped Replicate/model safety filters; model-specific `num_outputs` option set to 0 in request.extra; degenerate prediction on the platform.
Related errors
- No output received from Replicate.
- Replicate provider is not configured. Missing API Key.
- Output does not contain a recognizable image URL.
- Failed to generate image: ${artistryResult.error || 'No outp
- Failed to fetch image: ${response.statusText}
AI-assisted analysis of moeru-ai/airi@27111382b4 (2026-08-12).
Data as JSON: /api/errors/6d66a52afb2445bb.
Report an issue: GitHub.