CherryHQ/cherry-studio · error · Error
Rerank response must contain a results array
Error message
Rerank response must contain a results array
What it means
Thrown after the submit/poll cycle completed successfully but the resulting URL list is empty (covers both submit.imageUrls === [] and poll() === []). Unlike the malformed-submit case (error 400), the provider invocation genuinely finished — it just produced no images. The handler records the invocation with imageCount=0 BEFORE throwing, because the call was observable/billable, then fails to avoid reporting a silent zero-image 'success'. Typical cause is vendor-side content moderation or a degraded response that still charged.
Source
Thrown at packages/ai-sdk-provider/src/openai-compatible-reranking-model.ts:88
}
},
abortSignal,
fetch: this.config.fetch
})
return {
ranking: value,
response: {
body: rawValue
}
}
}
}
function parseRerankResponse(body: unknown, documentCount: number): RerankRanking {
const results = (body as OpenAICompatibleRerankResponse).results
if (!Array.isArray(results)) {
throw new Error('Rerank response must contain a results array')
}
return results.map((result) => {
if (typeof result !== 'object' || result === null) {
throw new Error('Rerank response results must be objects')
}
if (typeof result.index !== 'number' || typeof result.relevance_score !== 'number') {
throw new Error('Rerank response results must contain numeric index and relevance_score')
}
if (!Number.isInteger(result.index) || result.index < 0 || result.index >= documentCount) {
throw new Error('Rerank response results must reference a valid document index')
}
return { index: result.index, relevanceScore: result.relevance_score }
})
}View on GitHub (pinned to 726446b54c)
Solutions
- Revise the prompt to remove content likely to trip the vendor's moderation policy and retry.
- Check the vendor dashboard/console for moderation actions or policy flags on the account/model.
- Verify the requested image count (n) is >= 1 end-to-end through providerOptions.
- Try a different model id from the same provider to isolate whether the block is model-specific.
- Inspect the aiUsageRecord for the requestId (`custom-image:<jobId>`) — imageCount=0 with a recorded invocation confirms a vendor-side empty response.
Example fix
// No code fix exists at the caller — the provider genuinely returned nothing.
// Mitigation is operational: surface a user-facing message and offer retry with a sanitized prompt.
// before
try { await generateImageViaJob(payload) }
catch (e) { logger.error(e.message) }
// after: distinguish the moderation case for the user
try { await generateImageViaJob(payload) }
catch (e) {
if (/completed but returned no image URLs/.test(e.message)) {
notifyUser('The model produced no image (possibly content moderation). Try a different prompt.')
} else { throw e }
} Defensive patterns
Strategy: try-catch
Validate before calling
// The empty-list case comes from the vendor post-success; you cannot fully
// prevent it client-side, but you can pre-validate inputs that commonly trip moderation.
const MODERATION_RISK = /(violence|explicit|weapon)/i
if (input.prompt && MODERATION_RISK.test(input.prompt)) {
warnUser('Prompt may be filtered by the model content policy.')
} Try / catch
try {
await generateImageViaJob(payload)
} catch (e) {
if (e instanceof Error && /completed but returned no image URLs/.test(e.message)) {
notifyUser('The model produced no image — likely content moderation. Revise the prompt and retry.')
} else throw e
} Prevention
- Sanitize prompts of terms known to trip the vendor's content policy before submitting.
- Track the aiUsageRecord (requestId custom-image:<jobId>) to correlate paid-but-empty invocations.
- Offer the user a model fallback so a single model's moderation does not block the workflow.
When it happens
Trigger: The prompt or input image triggers the vendor's safety/content-moderation filter, which returns a 200 with an empty result array instead of an error; a requested image count of n=0 propagated through; a degraded vendor path that accepts the request but yields no output URLs; an async poll that resolved to an empty array while reporting success.
Common situations: Prompt contains disallowed content or copyrighted names; input image is flagged by safety models; vendor temporarily degrades and returns zero results; the n parameter was overridden to 0 somewhere in option mapping; region/account under a content-policy shadow-ban.
Related errors
- OpenAI-compatible reranking model only supports text documen
- Rerank response results must be objects
- Rerank response results must contain numeric index and relev
- Failed to generate image: ${error.message}
- Failed to resolve image model: ${modelId} for provider: ${pr
AI-assisted analysis of CherryHQ/cherry-studio@726446b54c (2026-08-12).
Data as JSON: /api/errors/cc51f0cd639c7306.
Report an issue: GitHub.