can1357/oh-my-pi · error

flickr getSizes response did not include sizes

Error message

flickr getSizes response did not include sizes

What it means

largestFlickrSource() throws this when the getSizes response reports stat 'ok' but the sizes array is missing or not an array. The uploader relies on the sizes list to pick the largest available image URL.

Source

Thrown at packages/coding-agent/src/blob-broker/uploaders-image-hosts.ts:251

	for (const [option, parameter] of mappings) {
		const value = optionString(config, option);
		if (value) fields[parameter] = value;
	}
	return fields;
}

function flickrPhotoId(xml: string): string {
	const status = /<rsp\b[^>]*\b(?:stat|status)=["']([^"']+)["']/i.exec(xml)?.[1];
	if (status && status !== "ok") throw new Error("flickr rejected the upload");
	const photoId = /<photoid\b[^>]*>([^<]+)<\/photoid>/i.exec(xml)?.[1]?.trim();
	if (!photoId) throw new Error("flickr response did not include a photo ID");
	return photoId;
}

function largestFlickrSource(payload: Record<string, unknown>): string {
	if (payload.stat !== "ok") throw new Error("flickr getSizes request failed");
	const sizes = nestedRecord(payload, "sizes", "flickr").size;
	if (!Array.isArray(sizes)) throw new Error("flickr getSizes response did not include sizes");
	for (let index = sizes.length - 1; index >= 0; index--) {
		const size = sizes[index];
		if (size && typeof size === "object" && !Array.isArray(size)) {
			const source = (size as Record<string, unknown>).source;
			if (typeof source === "string" && source) return directUrl(source, "flickr");
		}
	}
	throw new Error("flickr getSizes response did not include a direct image URL");
}

function createFlickrUploader(config: DestinationRuntimeConfig): BlobUploader {
	const credentials: FlickrOAuthCredentials = {
		consumerKey: requireCredential(config, "apiKey"),
		consumerSecret: requireCredential(config, "apiSecret"),
		token: requireCredential(config, "oauthToken"),
		tokenSecret: requireCredential(config, "oauthTokenSecret"),
	};
	const uploadFields = flickrUploadFields(config);

View on GitHub (pinned to 9690622007)

Solutions

  1. Log the getSizes JSON payload and confirm the shape (rsp.sizes.size should be an array)
  2. Retry — the photo may not have been fully processed yet right after upload
  3. Check for API version changes in Flickr's flickr.photos.getSizes documentation
  4. Normalize a single-object size response to an array before the Array.isArray check

Example fix

// before
const sizes = nestedRecord(payload, "sizes", "flickr").size;
if (!Array.isArray(sizes)) throw new Error("flickr getSizes response did not include sizes");
// after
const rawSizes = nestedRecord(payload, "sizes", "flickr").size;
const sizes = Array.isArray(rawSizes) ? rawSizes : rawSizes ? [rawSizes] : null;
if (!sizes) throw new Error("flickr getSizes response did not include sizes");
Defensive patterns

Strategy: type-guard

Validate before calling

const sizes = payload?.sizes?.size;
if (!Array.isArray(sizes) || sizes.length === 0) throw new Error("getSizes returned no sizes yet; retry later");

Type guard

function hasSizes(payload: unknown): payload is { sizes: { size: unknown[] } } {
	const p = payload as Record<string, any> | null;
	return !!p && Array.isArray(p.sizes?.size);
}

Try / catch

try {
	const src = largestFlickrSource(payload);
} catch (err) {
	if (err instanceof Error && err.message.includes("did not include sizes")) {
		// normalize single-object size or retry after processing delay
	}
	throw err;
}

Prevention

When it happens

Trigger: Flickr returned a successful envelope whose sizes.sizes.size field is absent, null, or a single object instead of an array — e.g. an unexpected API schema, empty photo record, or a differently-shaped response from a proxy.

Common situations: Flickr API schema drift, an empty/placeholder photo record, middleware rewriting the JSON, or calling getSizes on a photo still being processed.

Related errors


AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31). Data as JSON: /api/errors/4e9b104c4802147e. Report an issue: GitHub.