{"record":{"id":"0001f1f46da239fa","repo":"can1357/oh-my-pi","slug":"unknown-security-scan-scanid","errorCode":null,"errorMessage":"Unknown security scan: ${scanId}","messagePattern":"Unknown security scan: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/internal-urls/security-protocol.ts","lineNumber":149,"sourceCode":"\t\t\t\t\t\"- `security://scans` — list scans\",\n\t\t\t\t\t\"\",\n\t\t\t\t].join(\"\\n\"),\n\t\t\t\tcontentType: \"text/markdown\",\n\t\t\t\tisDirectory: true,\n\t\t\t});\n\t\t}\n\t\tif (parts[0] !== \"scans\") throw new Error(`Unknown security resource: security://${parts.join(\"/\")}`);\n\t\tif (parts.length === 1) {\n\t\t\treturn createSecurityResource({\n\t\t\t\turl: \"security://scans\",\n\t\t\t\tcontent: formatScans(await store.listScans()),\n\t\t\t\tcontentType: \"text/markdown\",\n\t\t\t\tisDirectory: true,\n\t\t\t});\n\t\t}\n\t\tconst scanId = parts[1];\n\t\tconst bundle = await store.getBundle(scanId);\n\t\tif (!bundle) throw new Error(`Unknown security scan: ${scanId}`);\n\t\tif (parts.length === 2) {\n\t\t\treturn createSecurityResource({\n\t\t\t\turl: `security://scans/${scanId}`,\n\t\t\t\tcontent: [\n\t\t\t\t\t`# Security scan ${scanId}`,\n\t\t\t\t\t\"\",\n\t\t\t\t\t`- Status: **${bundle.scan.status}**`,\n\t\t\t\t\t`- Producer: **${sanitizeText(bundle.scan.producer.name)}**`,\n\t\t\t\t\t`- Findings: **${bundle.findings.length}**`,\n\t\t\t\t\t`- Coverage: **${bundle.scan.coverage.completeness}**`,\n\t\t\t\t\t`- Target: \\`${sanitizeText(bundle.scan.target.displayName)}\\``,\n\t\t\t\t\t\"\",\n\t\t\t\t\t\"Resources: `manifest`, `findings`, `coverage`, `report`, `sarif`, `provenance`.\",\n\t\t\t\t\t\"\",\n\t\t\t\t].join(\"\\n\"),\n\t\t\t\tcontentType: \"text/markdown\",\n\t\t\t\tisDirectory: true,\n\t\t\t});","sourceCodeStart":131,"sourceCodeEnd":167,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/internal-urls/security-protocol.ts#L131-L167","documentation":"For URLs of the form security://scans/<id>/..., resolve() fetches the scan bundle from the SecurityStore via store.getBundle(scanId); if no stored scan matches the id, it throws \"Unknown security scan: <scanId>\". This means the scan id is not present in the project's security store.","triggerScenarios":"Resolving security://scans/<id> or any deeper resource where <id> was deleted, belongs to a different project's store (store resolution is cwd-based), was never created, or is a stale id cached in a prompt/notes from a previous session or store reset.","commonSituations":"Referencing a scan id after the security store directory was cleared or the scan pruned; switching working directories so a different SecurityStore is opened; hallucinated or truncated scan ids in agent-generated URLs; rerunning against a fresh clone with no stored scans.","solutions":["List valid ids by resolving security://scans and use one of the returned scan ids.","Run a new security scan to generate a bundle if the referenced scan was deleted or belongs to a previous store.","Verify you are resolving from the same project working directory where the scan was stored (the store is resolved per-cwd).","If the id came from a cached note/prompt, refresh it — scan ids are not stable across store resets."],"exampleFix":"// before\nawait resolve(new URL(\"security://scans/old-scan-id/report\"));\n// after — look up a real id first\nconst scans = await store.listScans();\nconst id = scans[0]?.id;\nif (id) await resolve(new URL(`security://scans/${id}/report`));","handlingStrategy":"validation","validationCode":"async function resolveExistingScan(store: SecurityStore, scanId: string): Promise<ScanBundle> {\n  const bundle = await store.getBundle(scanId);\n  if (!bundle) {\n    const scans = await store.listScans();\n    const ids = scans.map(s => s.id).join(\", \") || \"none\";\n    throw new Error(`Scan \"${scanId}\" not found in store. Stored scans: ${ids}`);\n  }\n  return bundle;\n}\n// call before building any security://scans/<id>/... URL","typeGuard":"async function scanExists(store: SecurityStore, scanId: string): Promise<boolean> {\n  return (await store.listScans()).some(s => s.id === scanId);\n}","tryCatchPattern":"try {\n  return await handler.resolve(url, ctx);\n} catch (err) {\n  if (err instanceof Error && err.message.startsWith(\"Unknown security scan:\")) {\n    const listing = await handler.resolve(new URL(\"security://scans\"), ctx);\n    return listing; // show available scans instead of failing\n  }\n  throw err;\n}","preventionTips":["Resolve security://scans first and pick ids from the listing; never invent or truncate scan ids.","Remember the store is per-cwd — resolve URLs from the same working directory that produced the scan.","Refresh cached scan references after store resets, cleanups, or re-scans.","Verify scan status before deep-linking into sub-resources of a potentially pruned scan."],"tags":["internal-urls","not-found","stale-reference"],"backgroundTag":"resource-not-found","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}