{"record":{"id":"79fdffc902c81b5f","repo":"can1357/oh-my-pi","slug":"could-not-resolve-image-attachment-options-path","errorCode":null,"errorMessage":"Could not resolve image attachment '${options.path}'. Available image attachments: ${available}. Pass an attachment URI or a readable filesystem path.","messagePattern":"Could not resolve image attachment '(.+?)'\\. Available image attachments: (.+?)\\. Pass an attachment URI or a readable filesystem path\\.","errorType":"validation","errorClass":"ToolError","httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/tools/inspect-image.ts","lineNumber":83,"sourceCode":"\treturn attachments.map(attachment => `${attachment.label} -> ${attachment.uri}`).join(\", \");\n}\n\nasync function loadAttachmentReferenceInput(options: {\n\tpath: string;\n\treference: ImageAttachmentReference;\n\tattachments: readonly { label: string; uri: string; image: ImageContent }[];\n\tautoResize: boolean;\n\texcludeWebP: boolean | undefined;\n}): Promise<LoadedImageInput | null> {\n\tconst attachment = options.attachments[options.reference.index - 1];\n\tif (!attachment) {\n\t\tconst available = formatAvailableImageAttachments(options.attachments);\n\t\tif (options.attachments.length === 0) {\n\t\t\tthrow new ToolError(\n\t\t\t\t`No image attachments are available in this turn. path=\"${options.path}\" must be a readable file path or attachment URI.`,\n\t\t\t);\n\t\t}\n\t\tthrow new ToolError(\n\t\t\t`Could not resolve image attachment '${options.path}'. Available image attachments: ${available}. Pass an attachment URI or a readable filesystem path.`,\n\t\t);\n\t}\n\treturn loadImageAttachmentInput({\n\t\timage: attachment.image,\n\t\tlabel: attachment.label,\n\t\turi: attachment.uri,\n\t\tautoResize: options.autoResize,\n\t\tmaxBytes: MAX_IMAGE_INPUT_BYTES,\n\t\texcludeWebP: options.excludeWebP,\n\t});\n}\n\nexport interface InspectImageToolDetails {\n\tmodel: string;\n\timagePath: string;\n\tmimeType: string;\n\tusage: Usage;","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/tools/inspect-image.ts#L65-L101","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Use one of the attachment URIs exactly as listed in the error's 'Available image attachments' output.","Remember the index is 1-based: attachment index N maps to attachments[N-1].","Verify the path exists and is readable if intending a filesystem path (ls the file first).","Re-list current-turn attachments (e.g. from the latest image tool result) instead of reusing stale indices."],"exampleFix":"// before\ninspect_image({ path: \"attachment://3\" }) // only 2 attachments\n// after\ninspect_image({ path: \"attachment://2\" })","handlingStrategy":"validation","validationCode":"const idx = parseAttachmentIndex(params.path); // attachment://N -> N\nif (idx != null && (idx < 1 || idx > attachments.length)) {\n  throw new Error(`attachment index ${idx} out of range; 1..${attachments.length} available`);\n}","typeGuard":null,"tryCatchPattern":"try {\n  return await inspectImage({ path });\n} catch (err) {\n  if (err instanceof ToolError && err.message.includes('Could not resolve image attachment')) {\n    const available = err.message.match(/Available image attachments: (.+)\\./)?.[1];\n    // pick a valid reference from `available` and retry\n  } else throw err;\n}","preventionTips":["Treat attachment indices as 1-based and bounds-check before use","Copy attachment URIs from the same turn's tool output, not from memory","Parse the 'Available image attachments' list in the error to self-correct"],"tags":["validation","attachments","image-inspection","path-resolution"],"backgroundTag":"resource-not-found","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}