{"record":{"id":"557786d2781378e6","repo":"can1357/oh-my-pi","slug":"unknown-security-scan-scanid-557786","errorCode":null,"errorMessage":"Unknown security scan: ${scanId}","messagePattern":"Unknown security scan: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/slash-commands/helpers/security.ts","lineNumber":194,"sourceCode":"\tconst scanId = tokens[0];\n\tif (!scanId) throw new Error(\"export requires <scan-id> --output <path> [--format bundle|sarif|report]\");\n\tlet outputPath: string | undefined;\n\tlet format: \"bundle\" | \"sarif\" | \"report\" = \"bundle\";\n\tfor (let index = 1; index < tokens.length; index++) {\n\t\tconst token = tokens[index]!;\n\t\tif (token === \"--output\") outputPath = requireToken(tokens, ++index, token);\n\t\telse if (token === \"--format\") {\n\t\t\tconst value = requireToken(tokens, ++index, token);\n\t\t\tif (value !== \"bundle\" && value !== \"sarif\" && value !== \"report\") {\n\t\t\t\tthrow new Error(`Unknown export format: ${value}`);\n\t\t\t}\n\t\t\tformat = value;\n\t\t} else throw new Error(`Unknown export option: ${token}`);\n\t}\n\tif (!outputPath) throw new Error(\"export requires --output <path>\");\n\tconst store = await SecurityStore.openForCwd(runtime.cwd);\n\tconst bundle = await store.getBundle(scanIdFromInput(scanId));\n\tif (!bundle) throw new Error(`Unknown security scan: ${scanId}`);\n\tlet content: string;\n\tif (format === \"sarif\") {\n\t\tif (!bundle.sarif) throw new Error(`Security scan ${scanId} has no SARIF result`);\n\t\tcontent = `${JSON.stringify(bundle.sarif, null, 2)}\\n`;\n\t} else if (format === \"report\") {\n\t\tif (bundle.report === undefined) throw new Error(`Security scan ${scanId} has no report`);\n\t\tcontent = bundle.report;\n\t} else {\n\t\tcontent = `${JSON.stringify(bundle, null, 2)}\\n`;\n\t}\n\tconst absolute = path.resolve(runtime.cwd, outputPath);\n\tawait writeSecurityFileAtomic(absolute, content, { hardenParent: false });\n\tawait runtime.output(`Exported security scan ${scanId} to ${shortenPath(absolute)}.`);\n}\n\ninterface CloudCliOptions {\n\tcredentialId?: number;\n\tconfigurationId?: string;","sourceCodeStart":176,"sourceCodeEnd":212,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/slash-commands/helpers/security.ts#L176-L212","documentation":"The scan id given to /security export does not correspond to any stored security scan. exportResults() calls store.getBundle(scanIdFromInput(scanId)) and throws this templated error when the store returns null/undefined. The input is normalized via scanIdFromInput, so both raw ids and scan URIs are accepted, but the resolved id must exist in the SecurityStore for the current repository.","triggerScenarios":"Typo in the scan id; exporting a scan stored in a different repository/cwd (SecurityStore.openForCwd is cwd-scoped); the scan was deleted or the store was reset; passing a finding URI instead of a scan URI so scanIdFromInput extracts the wrong id.","commonSituations":"Working in a different checkout than where the scan was imported; stale scan id copied from old session output; id from another machine's store.","solutions":["List available scans (e.g. /security list) and copy an exact valid scan id","Run the command from the same repository/cwd where the scan was imported","Verify the id: pass security://scans/<scan-id> or the bare scan id, not a findings URI","Re-import the SARIF/bundle if the scan no longer exists in this store"],"exampleFix":"// before\n/security export scan-XYZ-doesnotexist --output out.json\n// after\n/security list\n/security export scan-abc --output out.json","handlingStrategy":"validation","validationCode":"// resolve the scan id from the same cwd/session before exporting:\nasync function scanExists(store: { getBundle(id: string): Promise<unknown> }, id: string) {\n  return (await store.getBundle(id)) != null;\n}\n// or list scans first and pick an id from the output","typeGuard":null,"tryCatchPattern":"try {\n  await runSlashCommand(`/security export ${scanId} --output out.json`);\n} catch (err) {\n  if (err instanceof Error && err.message.startsWith(\"Unknown security scan:\")) {\n    // list scans, fix the id, or re-import the source\n  } else throw err;\n}","preventionTips":["Copy scan ids from /security list output rather than retyping them","Run export from the same repository/cwd where the scan was imported (the store is cwd-scoped)","Pass the scan id (or security://scans/<id>), not a findings URI","Re-import the SARIF/bundle if the store was cleared or migrated"],"tags":["cli","not-found","slash-command","state"],"backgroundTag":"resource-not-found","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}