can1357/oh-my-pi · error · ToolError

Could not resolve image attachment '${options.path}'. Availa

Error message

Could not resolve image attachment '${options.path}'. Available image attachments: ${available}. Pass an attachment URI or a readable filesystem path.

What it means

Companion to the empty-attachments case: attachments exist this turn, but the given path does not match any of them (wrong index, wrong URI format, or a non-attachment path that is also not readable as a file). The error enumerates the available image attachments so the caller can pick a valid reference.

Source

Thrown at packages/coding-agent/src/tools/inspect-image.ts:83

	return attachments.map(attachment => `${attachment.label} -> ${attachment.uri}`).join(", ");
}

async function loadAttachmentReferenceInput(options: {
	path: string;
	reference: ImageAttachmentReference;
	attachments: readonly { label: string; uri: string; image: ImageContent }[];
	autoResize: boolean;
	excludeWebP: boolean | undefined;
}): Promise<LoadedImageInput | null> {
	const attachment = options.attachments[options.reference.index - 1];
	if (!attachment) {
		const available = formatAvailableImageAttachments(options.attachments);
		if (options.attachments.length === 0) {
			throw new ToolError(
				`No image attachments are available in this turn. path="${options.path}" must be a readable file path or attachment URI.`,
			);
		}
		throw new ToolError(
			`Could not resolve image attachment '${options.path}'. Available image attachments: ${available}. Pass an attachment URI or a readable filesystem path.`,
		);
	}
	return loadImageAttachmentInput({
		image: attachment.image,
		label: attachment.label,
		uri: attachment.uri,
		autoResize: options.autoResize,
		maxBytes: MAX_IMAGE_INPUT_BYTES,
		excludeWebP: options.excludeWebP,
	});
}

export interface InspectImageToolDetails {
	model: string;
	imagePath: string;
	mimeType: string;
	usage: Usage;

View on GitHub (pinned to 9690622007)

Solutions

  1. Use one of the attachment URIs exactly as listed in the error's 'Available image attachments' output.
  2. Remember the index is 1-based: attachment index N maps to attachments[N-1].
  3. Verify the path exists and is readable if intending a filesystem path (ls the file first).
  4. Re-list current-turn attachments (e.g. from the latest image tool result) instead of reusing stale indices.

Example fix

// before
inspect_image({ path: "attachment://3" }) // only 2 attachments
// after
inspect_image({ path: "attachment://2" })
Defensive patterns

Strategy: validation

Validate before calling

const idx = parseAttachmentIndex(params.path); // attachment://N -> N
if (idx != null && (idx < 1 || idx > attachments.length)) {
  throw new Error(`attachment index ${idx} out of range; 1..${attachments.length} available`);
}

Try / catch

try {
  return await inspectImage({ path });
} catch (err) {
  if (err instanceof ToolError && err.message.includes('Could not resolve image attachment')) {
    const available = err.message.match(/Available image attachments: (.+)\./)?.[1];
    // pick a valid reference from `available` and retry
  } else throw err;
}

Prevention

When it happens

Trigger: Calling inspect-image with a path/attachment URI whose index exceeds the attachment list or fails to resolve to one of the current attachments, while attachments.length > 0, at inspect-image.ts:83.

Common situations: 1-based vs 0-based index confusion; referencing attachment://3 when only 2 images exist; hardcoding an index from a previous turn's list; typos in a file path that is also not a valid attachment URI.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


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