{"record":{"id":"c3a79a1b9fa7f0ba","repo":"affaan-m/ECC","slug":"orch-review-args-diff-must-be-a-non-empty-unified-diff","errorCode":null,"errorMessage":"orch-review: args.diff must be a non-empty unified diff","messagePattern":"orch-review: args\\.diff must be a non-empty unified diff","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"workflows/orch-review.workflow.js","lineNumber":162,"sourceCode":"}\n\n// --- main -----------------------------------------------------------------\n\n// `args` arrives verbatim. Accept a JSON-encoded string too, so the workflow\n// works whether the caller passes an object or a stringified payload.\n// Fail CLOSED on invalid input: a review gate must never silently APPROVE a\n// payload it could not actually review.\nlet input;\ntry {\n  input = typeof args === 'string' ? JSON.parse(args) : (args ?? {});\n} catch {\n  throw new Error('orch-review: args must be an object or valid JSON');\n}\nif (typeof input !== 'object' || input === null) {\n  throw new Error('orch-review: args must be an object');\n}\nif (typeof input.diff !== 'string' || input.diff.trim() === '') {\n  throw new Error('orch-review: args.diff must be a non-empty unified diff');\n}\nif (input.changedFiles != null && !Array.isArray(input.changedFiles)) {\n  throw new Error('orch-review: args.changedFiles must be an array of paths');\n}\n// Every entry must be a string path. A non-string (e.g. { path: '...' }) would\n// stringify to \"[object Object]\" and silently poison the security-trigger\n// haystack — fail closed on malformed input instead.\nif (Array.isArray(input.changedFiles) && !input.changedFiles.every(f => typeof f === 'string')) {\n  throw new Error('orch-review: args.changedFiles must contain only string paths');\n}\n\nconst diff = input.diff;\nconst haystack = `${diff}\\n${(input.changedFiles || []).join('\\n')}`;\n\n// Build the review dimensions immutably. Quality always runs; language +\n// security are conditional, spread in rather than pushed onto a shared array.\nconst langReviewer = input.language && LANGUAGE_REVIEWER[String(input.language).toLowerCase()];\nconst securityNeeded = SECURITY_TRIGGER.test(haystack);","sourceCodeStart":144,"sourceCodeEnd":180,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/workflows/orch-review.workflow.js#L144-L180","documentation":"The workflow requires args.diff to be a non-empty string containing the unified diff under review. A missing, non-string, or whitespace-only diff cannot be reviewed, so the gate throws instead of returning an empty/approving result.","triggerScenarios":"Calling with { changedFiles: [...] } but no diff key; { diff: '' } or { diff: '   ' }; diff set to null/undefined or a non-string (e.g. an array of file contents); upstream git diff command returned empty output that was passed straight through.","commonSituations":"Diff generation failed silently (git diff ran outside a repo, wrong ref) yielding '' ; callers renamed the key (patch/changes) ; automation building the payload omitted diff when there were no changes.","solutions":["Populate args.diff with the actual unified diff text before invoking; fail early in the caller if it is empty.","Verify the diff-generation command actually ran in a git repo against the intended ref.","Rename the key to `diff` if your producer used `patch` or another name.","If there are genuinely no changes, skip invoking the review workflow instead of passing an empty diff."],"exampleFix":"// before\nreview({ changedFiles: ['a.js'] }); // no diff\n// after\nconst diff = execSync('git diff HEAD~1').toString();\nif (!diff.trim()) throw new Error('no changes to review');\nreview({ diff, changedFiles: ['a.js'] });","handlingStrategy":"validation","validationCode":"if (typeof diff !== 'string' || diff.trim() === '') {\n  throw new Error('Refusing to review: diff is empty or not a string');\n}","typeGuard":"const hasDiff = p => typeof p?.diff === 'string' && p.diff.trim().length > 0;","tryCatchPattern":"try {\n  const result = await orchReview({ diff, changedFiles });\n} catch (err) {\n  if (err.message.includes('args.diff must be a non-empty unified diff')) {\n    console.error('Diff generation produced nothing; check repo state and ref before reviewing.');\n  } else throw err;\n}","preventionTips":["Capture git diff output and assert it is non-empty before invoking the gate.","Use the exact key name `diff` in the payload.","Skip the workflow entirely when there are no changes instead of passing an empty diff."],"tags":["validation","empty-input","fail-closed"],"backgroundTag":"empty-required-field","analyzedSha":"8321021c54d670126ce3b2969d5deb880b4b0c2a","analyzedAt":"2026-09-16T10:08:13.343Z","contentChangedAt":"2026-09-16T10:08:13.343Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}