{"record":{"id":"926789182a1251fe","repo":"affaan-m/ECC","slug":"unknown-argument-arg","errorCode":null,"errorMessage":"Unknown argument: ${arg}","messagePattern":"Unknown argument: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/auto-update.js","lineNumber":47,"sourceCode":"  };\n\n  for (let index = 0; index < args.length; index += 1) {\n    const arg = args[index];\n\n    if (arg === '--target') {\n      parsed.targets.push(args[index + 1] || null);\n      index += 1;\n    } else if (arg === '--repo-root') {\n      parsed.repoRoot = args[index + 1] || null;\n      index += 1;\n    } else if (arg === '--dry-run') {\n      parsed.dryRun = true;\n    } else if (arg === '--json') {\n      parsed.json = true;\n    } else if (arg === '--help' || arg === '-h') {\n      parsed.help = true;\n    } else {\n      throw new Error(`Unknown argument: ${arg}`);\n    }\n  }\n\n  return parsed;\n}\n\nfunction deriveRepoRootFromState(state) {\n  const operations = Array.isArray(state && state.operations) ? state.operations : [];\n\n  for (const operation of operations) {\n    if (typeof operation.sourcePath !== 'string' || !operation.sourcePath.trim()) {\n      continue;\n    }\n\n    if (typeof operation.sourceRelativePath !== 'string' || !operation.sourceRelativePath.trim()) {\n      continue;\n    }\n","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/affaan-m/ECC/blob/01e15490f04e29cfefe3896951f43db46994d8ee/scripts/auto-update.js#L29-L65","documentation":"After successfully parsing args (or receiving a non-string value), the workflow requires the result to be a non-null object. This throw fires when the parsed value is a primitive (number, boolean, string), null, or an array — anything that is not a plain object holding a `diff` field. The review contract is object-shaped; an array or scalar cannot satisfy it.","triggerScenarios":"Passing args as a JSON array string '[\"file.js\"]'; passing a bare diff string 'orchReview(\"--- a\\n...\")'; passing a number/boolean; passing args = null.","commonSituations":"Caller passes the raw diff text directly instead of wrapping it in { diff: ... }; caller passes a list of files instead of the expected object envelope; args defaults to null somewhere upstream.","solutions":["Wrap the payload in an object with a `diff` key: { diff: unifiedDiff, changedFiles: [...] }.","If you previously passed a bare string, move that string into the `diff` property.","Add a runtime type check in the caller: typeof payload === 'object' && payload !== null && !Array.isArray(payload)."],"exampleFix":"// before\norchReview('--- a\\n+++ b\\n'); // bare diff string parses to a string, not object\n\n// after\norchReview({ diff: '--- a\\n+++ b\\n', changedFiles: ['b'] });","handlingStrategy":"type-guard","validationCode":"// Confirm the payload is a non-null, non-array object before calling.\nconst ok = typeof input === 'object' && input !== null && !Array.isArray(input);\nif (!ok) throw new Error('orch-review payload must be a plain object with a diff field');","typeGuard":"function isReviewPayload(v) {\n  return typeof v === 'object' && v !== null && !Array.isArray(v) && typeof v.diff === 'string';\n}","tryCatchPattern":"try {\n  orchReview(payload);\n} catch (e) {\n  if (e.message === 'orch-review: args must be an object') {\n    payload = { diff: String(payload) }; // wrap a bare value, then retry\n    orchReview(payload);\n  }\n}","preventionTips":["Always wrap your review data in { diff, changedFiles } — never pass a bare diff or array.","Add a type check in the caller so mis-shaped payloads fail there, not inside the gate."],"tags":["validation","json","workflow","type","review-gate"],"backgroundTag":null,"analyzedSha":"01e15490f04e29cfefe3896951f43db46994d8ee","analyzedAt":"2026-08-13T00:31:08.655Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}