affaan-m/ECC · error · Error

orch-review: args.diff must be a non-empty unified diff

Error message

orch-review: args.diff must be a non-empty unified diff

What it means

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.

Solutions

  1. Populate args.diff with the actual unified diff text before invoking; fail early in the caller if it is empty.
  2. Verify the diff-generation command actually ran in a git repo against the intended ref.
  3. Rename the key to `diff` if your producer used `patch` or another name.
  4. If there are genuinely no changes, skip invoking the review workflow instead of passing an empty diff.

Example fix

// before
review({ changedFiles: ['a.js'] }); // no diff
// after
const diff = execSync('git diff HEAD~1').toString();
if (!diff.trim()) throw new Error('no changes to review');
review({ diff, changedFiles: ['a.js'] });
Defensive patterns

Strategy: validation

Validate before calling

if (typeof diff !== 'string' || diff.trim() === '') {
  throw new Error('Refusing to review: diff is empty or not a string');
}

Type guard

const hasDiff = p => typeof p?.diff === 'string' && p.diff.trim().length > 0;

Try / catch

try {
  const result = await orchReview({ diff, changedFiles });
} catch (err) {
  if (err.message.includes('args.diff must be a non-empty unified diff')) {
    console.error('Diff generation produced nothing; check repo state and ref before reviewing.');
  } else throw err;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.

Related errors


AI-assisted analysis of affaan-m/ECC@8321021c54 (2026-09-16). Data as JSON: /api/errors/c3a79a1b9fa7f0ba. Report an issue: GitHub.

Appendix: source

Thrown at workflows/orch-review.workflow.js:162

}

// --- main -----------------------------------------------------------------

// `args` arrives verbatim. Accept a JSON-encoded string too, so the workflow
// works whether the caller passes an object or a stringified payload.
// Fail CLOSED on invalid input: a review gate must never silently APPROVE a
// payload it could not actually review.
let input;
try {
  input = typeof args === 'string' ? JSON.parse(args) : (args ?? {});
} catch {
  throw new Error('orch-review: args must be an object or valid JSON');
}
if (typeof input !== 'object' || input === null) {
  throw new Error('orch-review: args must be an object');
}
if (typeof input.diff !== 'string' || input.diff.trim() === '') {
  throw new Error('orch-review: args.diff must be a non-empty unified diff');
}
if (input.changedFiles != null && !Array.isArray(input.changedFiles)) {
  throw new Error('orch-review: args.changedFiles must be an array of paths');
}
// Every entry must be a string path. A non-string (e.g. { path: '...' }) would
// stringify to "[object Object]" and silently poison the security-trigger
// haystack — fail closed on malformed input instead.
if (Array.isArray(input.changedFiles) && !input.changedFiles.every(f => typeof f === 'string')) {
  throw new Error('orch-review: args.changedFiles must contain only string paths');
}

const diff = input.diff;
const haystack = `${diff}\n${(input.changedFiles || []).join('\n')}`;

// Build the review dimensions immutably. Quality always runs; language +
// security are conditional, spread in rather than pushed onto a shared array.
const langReviewer = input.language && LANGUAGE_REVIEWER[String(input.language).toLowerCase()];
const securityNeeded = SECURITY_TRIGGER.test(haystack);

View on GitHub (pinned to 8321021c54)