{"record":{"id":"d82deaa9359aabd1","repo":"ruvnet/RuView","slug":"guidance-input-must-be-an-object-d82dea","errorCode":null,"errorMessage":"guidance input must be an object","messagePattern":"guidance input must be an object","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"harness/ruview/src/guidance.js","lineNumber":342,"sourceCode":" *   topic: string,\n *   query: string|null,\n *   summary: string,\n *   topics: Array<{topic: string, summary: string}>,\n *   capabilities: Array<object>,\n *   entryPoints: string[],\n *   recommendedCommands: string[],\n *   relatedKnowledge: object[],\n *   sourceCheck: object,\n *   authority: string\n * }} Structured guidance suitable for CLI or MCP serialization.\n * @throws {TypeError|RangeError} When called directly with malformed input.\n *\n * @example\n * getGuidance({ topic: 'homecore', query: 'Wasmtime plugin' });\n */\nexport function getGuidance(input = {}, options = {}) {\n  if (!input || typeof input !== 'object' || Array.isArray(input)) {\n    throw new TypeError('guidance input must be an object');\n  }\n  if (!options || typeof options !== 'object' || Array.isArray(options)) {\n    throw new TypeError('guidance options must be an object');\n  }\n  if (input.topic !== undefined && typeof input.topic !== 'string') {\n    throw new TypeError('guidance topic must be a string');\n  }\n  if (input.query !== undefined && typeof input.query !== 'string') {\n    throw new TypeError('guidance query must be a string');\n  }\n  if (input.limit !== undefined && (typeof input.limit !== 'number' || !Number.isFinite(input.limit))) {\n    throw new TypeError('guidance limit must be a finite number');\n  }\n  if (options.repoRoot !== undefined && options.repoRoot !== null && typeof options.repoRoot !== 'string') {\n    throw new TypeError('guidance repoRoot must be a string or null');\n  }\n  const topic = input.topic === undefined ? 'overview' : input.topic;\n  if (!GUIDANCE_TOPICS.includes(topic)) {","sourceCodeStart":324,"sourceCodeEnd":360,"githubUrl":"https://github.com/ruvnet/RuView/blob/4685618388a5e49fad5b3005806f3bdd6a7c25c3/harness/ruview/src/guidance.js#L324-L360","documentation":"getGuidance() is the RuView contributor-harness guidance API (harness/ruview/src/guidance.js). Its first argument must be a non-null, non-array object; the `= {}` default only applies when the argument is exactly undefined. Passing null, a primitive, or an array fails this guard before any other validation runs.","triggerScenarios":"Direct calls: getGuidance(null), getGuidance('homecore'), getGuidance(['overview']), getGuidance(42). Also forwarding raw JSON-RPC params (which the spec allows to be an array) or a JSON.parse result that is a string/array straight into input.","commonSituations":"MCP/JSON bridges that pass parsed-but-unshaped payloads; CLI code doing getGuidance(JSON.parse(raw)) where raw holds a JSON array; refactoring a function signature so callers pass the topic string positionally.","solutions":["Call getGuidance({}) or getGuidance({ topic: 'overview' }) with an object literal.","If input comes from JSON or RPC, shape it before calling: if (typeof input !== 'object' || input === null || Array.isArray(input)) input = {};","For positional arrays, map to named fields first (e.g. { topic: args[0], query: args[1] })."],"exampleFix":"// before\ngetGuidance(mcpParams) // mcpParams is a positional array like [\"overview\"]\n// after\nconst input = Array.isArray(mcpParams)\n  ? { topic: mcpParams[0], query: mcpParams[1] }\n  : (mcpParams ?? {});\ngetGuidance(input);","handlingStrategy":"type-guard","validationCode":"const input = rawInput ?? {};\nif (typeof input !== 'object' || input === null || Array.isArray(input)) {\n  throw new Error(`guidance input must be an object, got ${Array.isArray(input) ? 'array' : typeof input}`);\n}\ngetGuidance(input);","typeGuard":"function isGuidanceInput(v) {\n  return typeof v === 'object' && v !== null && !Array.isArray(v);\n}","tryCatchPattern":"try {\n  getGuidance(input);\n} catch (e) {\n  if (e instanceof TypeError && e.message === 'guidance input must be an object') {\n    // normalize and retry once with a known-good shape\n    return getGuidance({});\n  }\n  throw e;\n}","preventionTips":["Always call getGuidance with an object literal at the boundary (CLI, MCP handler) instead of forwarding raw parsed JSON.","Treat external JSON as untrusted: parse, shape, then call.","Remember `= {}` defaults fire only on undefined, not null — never pass null explicitly."],"tags":["validation","guidance","typeerror","ruview-harness"],"backgroundTag":null,"analyzedSha":"4685618388a5e49fad5b3005806f3bdd6a7c25c3","analyzedAt":"2026-08-16T06:09:40.886Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}