can1357/oh-my-pi · error · ToolError

Unknown attachment URL in bash command: ${url}

Error message

Unknown attachment URL in bash command: ${url}

What it means

For 'attachment://' URLs, resolveInternalUrlToPath looks up the URI in the session's known attachment list. If no entry's uri matches the requested URL, it throws this ToolError because the attachment does not exist in the current session and there is no sourcePath to resolve to.

Source

Thrown at packages/coding-agent/src/tools/bash-skill-urls.ts:277

	localOptions?: LocalProtocolOptions,
	ensureLocalParentDirs?: boolean,
	cwd?: string,
	sessionFile?: string,
): Promise<string> {
	const url = normalizeLocalScheme(rawUrl);
	const scheme = extractScheme(url);
	if (!scheme) {
		throw new ToolError(`Unsupported internal URL in bash command: ${url}`);
	}

	if (scheme === "skill") {
		return resolveSkillUrlToPath(url, skills);
	}

	if (scheme === "attachment") {
		const attachment = attachments.find(entry => entry.uri === url);
		if (!attachment) {
			throw new ToolError(`Unknown attachment URL in bash command: ${url}`);
		}
		return path.resolve(attachment.sourcePath);
	}

	if (scheme === "local") {
		if (!localOptions) {
			throw new ToolError(
				"Cannot resolve local:// URL in bash command: local protocol options are unavailable for this session.",
			);
		}
		const resolvedLocalPath = resolveLocalUrlToPath(url, localOptions);
		if (ensureLocalParentDirs) {
			await fs.mkdir(path.dirname(resolvedLocalPath), { recursive: true });
		}
		return resolvedLocalPath;
	}

	if (!internalRouter?.canHandle(url)) {

View on GitHub (pinned to 9690622007)

Solutions

  1. List the session's current attachments and copy the exact attachment:// URI from there.
  2. Verify the command runs in the same session where the attachment was created.
  3. Fix typos or normalization differences in the URI (compare byte-for-byte against the registered entry.uri).
  4. Pass the file's source path directly instead of the attachment URL if you know it.

Example fix

// before
const cmd = `wc -c attachment://img-0042.png`; // not registered
// after
const cmd = `wc -c attachment://8f3a.../screenshot.png`; // exact URI from session attachments
Defensive patterns

Strategy: validation

Validate before calling

const known = new Set(attachments.map(a => a.uri));
if (!known.has(url)) throw new Error(`Attachment not in session: ${url}`);

Try / catch

try { await expandInternalUrls(cmd, ctx); } catch (e) { if (e instanceof ToolError && e.message.includes('Unknown attachment URL')) { /* list valid attachments and retry with correct URI */ } else throw e; }

Prevention

When it happens

Trigger: A bash command references attachment://<uri> but the uri is not among the ImageAttachmentEntry values captured for the session — the attachment was never added, was added in a different session, or the URI string differs (trailing slash, different id, typo).

Common situations: Referencing an attachment from a previous session or another agent run; hand-typing the attachment URI with the wrong id; an attachment that failed to load so it was never registered.

Related errors


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