{"record":{"id":"1a682fa18b10e8c8","repo":"can1357/oh-my-pi","slug":"not-found-target-navailable-availablestr","errorCode":null,"errorMessage":"Not found: ${target}\\nAvailable: ${availableStr}","messagePattern":"Not found: (.+?)\\\\nAvailable: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/internal-urls/agent-protocol.ts","lineNumber":96,"sourceCode":"\t\t\ttry {\n\t\t\t\treturn decodeURIComponent(segment);\n\t\t\t} catch {\n\t\t\t\treturn segment;\n\t\t\t}\n\t\t});\n\t\tconst nestedId =\n\t\t\tdecodedSegments.length > 0 && decodedSegments.every(segment => !segment.includes(\".\"))\n\t\t\t\t? [outputId, ...decodedSegments].join(\".\")\n\t\t\t\t: undefined;\n\n\t\tconst scan = await this.#findOutput(dirs, nestedId ? [nestedId, outputId] : [outputId]);\n\t\tif (!scan.anyDirExists) {\n\t\t\tthrow new Error(\"No artifacts directory found\");\n\t\t}\n\t\tif (!scan.foundPath) {\n\t\t\tconst target = nestedId ?? outputId;\n\t\t\tconst availableStr = scan.availableIds.size > 0 ? [...scan.availableIds].join(\", \") : \"none\";\n\t\t\tthrow new Error(`Not found: ${target}\\nAvailable: ${availableStr}`);\n\t\t}\n\n\t\tconst rawContent = await Bun.file(scan.foundPath).text();\n\t\tconst notes: string[] = [];\n\t\tlet content = rawContent;\n\t\tlet contentType: InternalResource[\"contentType\"] = \"text/markdown\";\n\n\t\t// Extraction applies only when the URL did NOT resolve to a nested output\n\t\t// (a slash that named a real child is a hierarchy hop, not a jq path).\n\t\tconst extract = hasQueryExtraction || (hasPathExtraction && scan.matchedId !== nestedId);\n\t\tif (extract) {\n\t\t\tlet jsonValue: unknown;\n\t\t\ttry {\n\t\t\t\tjsonValue = JSON.parse(rawContent);\n\t\t\t} catch (err) {\n\t\t\t\tconst message = err instanceof Error ? err.message : String(err);\n\t\t\t\tthrow new Error(`Output ${scan.matchedId} is not valid JSON: ${message}`);\n\t\t\t}","sourceCodeStart":78,"sourceCodeEnd":114,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/internal-urls/agent-protocol.ts#L78-L114","documentation":"At least one artifacts directory exists, but no <id>.md file matching the requested output ID (or its nested Parent.Child form) was found in any of them. The error lists the requested target and all available ids discovered across the scanned dirs, so the caller can pick a valid id. This is the 'wrong id / typo' case of agent:// resolution.","triggerScenarios":"Resolving agent://<id> where no <id>.md exists in any artifacts dir; agent://Parent/Child where neither Parent.Child.md nor Parent.md exists; misspelled id, id from a different (already finished) session, or a nested path whose segments contain dots (which disqualifies the nested-id form).","commonSituations":"Typo in the output id; referencing an output produced in a previous session that is no longer in the scanned registry dirs; referencing a subagent output before that subagent has written anything; case-sensitivity mismatches on case-sensitive filesystems.","solutions":["Use one of the ids listed in the 'Available:' portion of the error message","Run agent completion (handler.complete()) or list the artifacts dir to discover valid ids before resolving","Check the id belongs to a currently registered session (ids are per-session artifacts dirs)","For nested ids use dot-free path segments (agent://Parent/Child) so the Parent.Child hierarchy form is tried"],"exampleFix":"// before\nawait handler.resolve(parseUrl(\"agent://reviwer_0\"), ctx); // typo\n// after\nawait handler.resolve(parseUrl(\"agent://reviewer_0\"), ctx); // id from Available list","handlingStrategy":"try-catch","validationCode":"const dirs = artifactsDirsFromRegistry();\nconst available = new Set<string>();\nfor (const dir of dirs) {\n  try {\n    for (const f of await fs.readdir(dir)) {\n      if (f.endsWith(\".md\")) available.add(f.slice(0, -3));\n    }\n  } catch { /* ENOENT */ }\n}\nif (!available.has(outputId)) throw new Error(`Unknown id '${outputId}'. Available: ${[...available].join(\", \")}`);","typeGuard":null,"tryCatchPattern":"try {\n  const resource = await handler.resolve(url, context);\n} catch (err) {\n  if (err instanceof Error && err.message.startsWith(\"Not found:\")) {\n    const available = err.message.split(\"Available:\")[1]?.trim() ?? \"none\";\n    // suggest/choose from `available` ids and retry\n  } else throw err;\n}","preventionTips":["Use handler.complete() to list valid output ids before resolving","Copy ids exactly from agent output listings (watch for typos and case)","Remember ids are per-session; re-check after switching sessions","For nested outputs use dot-free slash segments (agent://Parent/Child)"],"tags":["not-found","url","agent-outputs","agent-protocol"],"backgroundTag":"resource-not-found","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}