{"record":{"id":"060d9daf6a5cfdb6","repo":"can1357/oh-my-pi","slug":"ref-diff-preflight-requires-base-revision-and-head","errorCode":null,"errorMessage":"ref_diff preflight requires base_revision and head_revision","messagePattern":"ref_diff preflight requires base_revision and head_revision","errorType":"validation","errorClass":"ToolError","httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/tools/security-scan.ts","lineNumber":72,"sourceCode":"\tcloudStats?: CodexSecurityCloudStats;\n\tcloudScan?: { id: string; repositoryUrl: string };\n\timportedScan?: { id: string; findingCount: number };\n}\n\nfunction targetFromParams(params: SecurityScanParams): SecurityTargetRequest {\n\tconst common = { includePaths: params.include_paths, excludePaths: params.exclude_paths };\n\tswitch (params.target_kind ?? \"repository\") {\n\t\tcase \"scoped_path\": {\n\t\t\tif (!params.include_paths?.some(value => value.trim().length > 0)) {\n\t\t\t\tthrow new ToolError(\"scoped_path security scans require at least one include path\");\n\t\t\t}\n\t\t\treturn { kind: \"scoped_path\", includePaths: params.include_paths, excludePaths: params.exclude_paths };\n\t\t}\n\t\tcase \"working_tree\":\n\t\t\treturn { kind: \"working_tree\", ...common };\n\t\tcase \"ref_diff\":\n\t\t\tif (!params.base_revision || !params.head_revision) {\n\t\t\t\tthrow new ToolError(\"ref_diff preflight requires base_revision and head_revision\");\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tkind: \"ref_diff\",\n\t\t\t\tbaseRevision: params.base_revision,\n\t\t\t\theadRevision: params.head_revision,\n\t\t\t\t...common,\n\t\t\t};\n\t\tdefault:\n\t\t\treturn { kind: \"repository\", ...common };\n\t}\n}\n\nfunction requireValue(value: string | undefined, label: string): string {\n\tif (!value?.trim()) throw new ToolError(`${label} is required for this action`);\n\treturn value.trim();\n}\n\nfunction cloudClientForSession(session: ToolSession, credentialId?: number): CodexSecurityCloudClient {","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/tools/security-scan.ts#L54-L90","documentation":"For target_kind='ref_diff', the scan compares two git revisions, so both base_revision and head_revision are required. If either is missing/empty, targetFromParams throws this preflight ToolError before any scanning starts.","triggerScenarios":"Calling security-scan with target_kind='ref_diff' and omitting base_revision, head_revision, or both; passing empty strings for either.","commonSituations":"Model forgets the revision pair when it wants to scan a diff; caller has only one of the two refs (e.g. HEAD but no base branch name); empty-string values from unset variables.","solutions":["Supply both base_revision and head_revision (branch names, tags, or SHAs), e.g. { target_kind: \"ref_diff\", base_revision: \"main\", head_revision: \"HEAD\" }","If you actually want the current state scanned, use target_kind='working_tree' or 'repository' instead","Validate both revision strings are non-empty before invoking"],"exampleFix":"// before\nscan({ target_kind: \"ref_diff\", head_revision: \"HEAD\" });\n// after\nscan({ target_kind: \"ref_diff\", base_revision: \"main\", head_revision: \"HEAD\" });","handlingStrategy":"validation","validationCode":"if (params.target_kind === \"ref_diff\" && (!params.base_revision?.trim() || !params.head_revision?.trim())) throw new Error(\"ref_diff needs both base_revision and head_revision\");","typeGuard":null,"tryCatchPattern":"try { await securityScan(params); } catch (e) { if (e instanceof ToolError && e.message.includes(\"ref_diff preflight\")) { return securityScan({ ...params, base_revision: params.base_revision || \"main\", head_revision: params.head_revision || \"HEAD\" }); } throw e; }","preventionTips":["Resolve both refs against the repo (git rev-parse) before scanning","Use 'HEAD' and a base branch explicitly rather than relying on defaults","Switch to working_tree kind when you don't actually need a diff"],"tags":["validation","security-scan","git"],"backgroundTag":"missing-required-parameter","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}