{"record":{"id":"84ad626a9ab4ec8d","repo":"affaan-m/ECC","slug":"orch-review-args-must-be-an-object","errorCode":null,"errorMessage":"orch-review: args must be an object","messagePattern":"orch-review: args must be an object","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"workflows/orch-review.workflow.js","lineNumber":159,"sourceCode":"    diff,\n    '----- END DIFF -----'\n  ].join('\\n');\n}\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 +","sourceCodeStart":141,"sourceCodeEnd":177,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/workflows/orch-review.workflow.js#L141-L177","documentation":"After JSON decoding, the workflow requires the resulting input to be an object. JSON primitives like numbers, strings, booleans, or arrays parsed from a JSON string (or a raw number/boolean passed directly) are rejected, again failing closed rather than reviewing the wrong shape.","triggerScenarios":"Passing args = 42, '\"a string\"', true, or a JSON string like '[1,2]' or 'null'-adjacent primitives such that typeof input !== 'object' (note: JSON strings that parse to arrays also fail this check).","commonSituations":"Callers passing the diff content itself instead of a wrapper object; wrappers double-encoding a payload; CLI arg parsing that converts the payload to a number/boolean; copying an array-based payload from another tool's API.","solutions":["Wrap the payload in an object with the expected keys, e.g. { diff, changedFiles }.","If passing JSON text, ensure it decodes to an object: '{\"diff\": ...}' not '...'.","Inspect the caller: a variable shadowing or type coercion may be replacing the object with a primitive."],"exampleFix":"// before\nrunWorkflow('orch-review', 'just the diff text');\n// after\nrunWorkflow('orch-review', { diff: 'just the diff text' });","handlingStrategy":"type-guard","validationCode":"if (typeof payload !== 'object' || payload === null || Array.isArray(payload)) {\n  throw new Error('orch-review payload must be a plain object');\n}","typeGuard":"const isPlainObject = v => v !== null && typeof v === 'object' && !Array.isArray(v);","tryCatchPattern":"try {\n  const result = await orchReview(args);\n} catch (err) {\n  if (err.message === 'orch-review: args must be an object') {\n    console.error('Wrap the payload: { diff, changedFiles }.');\n  } else throw err;\n}","preventionTips":["Always pass { diff, changedFiles } as an object; never the diff string itself.","Avoid double-encoding: if the caller JSON.stringifies, do not stringify again downstream.","Add an integration test asserting the payload shape before the workflow is called."],"tags":["validation","type-mismatch","fail-closed"],"backgroundTag":"schema-validation-failed","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"}