{"record":{"id":"9db68583aa9c0431","repo":"can1357/oh-my-pi","slug":"unknown-export-format-value","errorCode":null,"errorMessage":"Unknown export format: ${value}","messagePattern":"Unknown export format: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"info","filePath":"packages/coding-agent/src/slash-commands/helpers/security.ts","lineNumber":186,"sourceCode":"\t\t? await importCodexSecurityBundle(absolute, { repositoryRoot: store.repositoryRoot })\n\t\t: await importSarifFile(absolute, { repositoryRoot: store.repositoryRoot });\n\tawait store.putBundle(bundle);\n\tawait runtime.output(`Imported ${bundle.findings.length} finding(s) as security scan ${bundle.scan.id}.`);\n}\n\nasync function exportResults(runtime: SlashCommandRuntime, rest: string): Promise<void> {\n\tconst tokens = parseCommandArgs(rest);\n\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}","sourceCodeStart":168,"sourceCodeEnd":204,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/slash-commands/helpers/security.ts#L168-L204","documentation":"The --format option of /security export accepts only three values: bundle (default), sarif, or report. exportResults() throws this templated error when the token following --format is anything else. It validates the enum before any I/O so an invalid format never reaches the store or file writer.","triggerScenarios":"Running /security export <scan-id> --output <path> --format json (or pdf, xml, text, any value other than bundle/sarif/report); a script parameterizes the format with an unsupported value; typo variants like sariff or bundles.","commonSituations":"Developer assumes generic format names like json (the bundle is JSON but must be requested as bundle); automation config carries a stale format value from a different tool; case sensitivity mistakes such as --format SARIF (matching is exact lowercase).","solutions":["Use one of the exact lowercase values: --format bundle, --format sarif, or --format report","Fix typos (e.g. sariff -> sarif) and casing (SARIF -> sarif)","Drop the --format flag entirely to get the default bundle format"],"exampleFix":"// before\n/security export scan-abc --output out.json --format json\n// after\n/security export scan-abc --output out.json --format bundle","handlingStrategy":"validation","validationCode":"const EXPORT_FORMATS = [\"bundle\", \"sarif\", \"report\"] as const;\ntype ExportFormat = (typeof EXPORT_FORMATS)[number];\nfunction isExportFormat(v: string): v is ExportFormat {\n  return (EXPORT_FORMATS as readonly string[]).includes(v);\n}\n// before invoking: if (format && !isExportFormat(format)) fix format;","typeGuard":"function isExportFormat(value: string): value is \"bundle\" | \"sarif\" | \"report\" {\n  return value === \"bundle\" || value === \"sarif\" || value === \"report\";\n}","tryCatchPattern":"try {\n  await runSlashCommand(`/security export ${scanId} --output ${out} --format ${format}`);\n} catch (err) {\n  if (err instanceof Error && err.message.startsWith(\"Unknown export format:\")) {\n    // retry with default bundle format or a corrected value\n  } else throw err;\n}","preventionTips":["Use only lowercase bundle|sarif|report — matching is exact and case-sensitive","Type the format from the union type in code rather than free strings","Omit --format entirely to get the default bundle","Watch for typos: sariff, bundles, json are all rejected"],"tags":["cli","argument-validation","enum","slash-command","usage-error"],"backgroundTag":"invalid-enum-value","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}