HeyPuter/puter · error · HttpError
bad_request
bad_request
Error message
${providerLabel} supports only a single input image; pass one image via input_image or a single-element input_images. What it means
resolveSingleInputImage enforces that providers which only accept one input image (Cloudflare, and others using this helper) get at most one. If params.input_images is an array with length > 1, it throws HTTP 400 bad_request naming the providerLabel. Use input_image (single) or a single-element input_images array instead.
Source
Thrown at src/backend/drivers/ai-image/inputImage.ts:48
import { secureFetch } from '../../util/secureHttp.js';
import type { IGenerateParams } from './types.js';
export function isHttpUrl(s: string): boolean {
return s.startsWith('http://') || s.startsWith('https://');
}
/**
* Resolve the single input image for providers that only support one.
* Throws 400 if `input_images` carries more than one entry. Returns the
* chosen image string (URL / data-URI / raw base64) or undefined.
*/
export function resolveSingleInputImage(
params: Pick<IGenerateParams, 'input_image' | 'input_images'>,
providerLabel: string,
): string | undefined {
const imgs = params.input_images;
if (imgs && imgs.length > 1) {
throw new HttpError(
400,
`${providerLabel} supports only a single input image; pass one image via input_image or a single-element input_images.`,
{ legacyCode: 'bad_request' },
);
}
return params.input_image ?? imgs?.[0];
}
const DATA_URI_PATTERN = /^data:([^;,]+)?(?:;base64)?,(.*)$/s;
/** Parse a `data:<mime>;base64,<payload>` URI into raw base64 + mime. */
export function parseDataUri(
s: string,
): { base64: string; mime: string } | null {
const m = DATA_URI_PATTERN.exec(s);
if (!m) return null;
return { base64: m[2] ?? '', mime: m[1] ?? 'image/png' };
}View on GitHub (pinned to 908ec23eda)
Solutions
- Pass exactly one image via input_image or input_images: [img].
- Switch to a provider that supports multiple input images if you need them.
- Validate input length before the call based on the target provider's capability.
Example fix
// before
await driver.generate({ prompt, provider: 'cloudflare', input_images: [a, b] });
// after
await driver.generate({ prompt, provider: 'cloudflare', input_image: a }); Defensive patterns
Strategy: validation
Validate before calling
if (Array.isArray(args.input_images) && args.input_images.length > 1 && isSingleImageProvider(provider)) {
throw new Error(`${provider} accepts only one input image`);
} Type guard
function isSingleInputImageBundle(p) {
return Array.isArray(p.input_images) ? p.input_images.length <= 1 : true;
} Prevention
- For single-image providers, pass input_image or a one-element input_images.
- Branch on provider capability when collecting reference images in the UI.
- Validate array length before the call.
When it happens
Trigger: An image-editing/generation call to a single-image provider passes input_images with two or more entries.
Common situations: App built for a multi-image provider reused against Cloudflare/other single-image provider; UI that always collects an array of reference images; batch logic that forwards many thumbnails.
Related errors
AI-assisted analysis of HeyPuter/puter@908ec23eda (2026-08-12).
Data as JSON: /api/errors/9df80e1eff73cbc7.
Report an issue: GitHub.