{"record":{"id":"3170c1dea050b62a","repo":"ruvnet/RuView","slug":"guidance-options-must-be-an-object-3170c1","errorCode":null,"errorMessage":"guidance options must be an object","messagePattern":"guidance options must be an object","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"harness/ruview/src/guidance.js","lineNumber":345,"sourceCode":" *   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)) {\n    throw new RangeError(`unsupported guidance topic: ${topic}`);\n  }\n  const query = input.query === undefined ? '' : input.query.trim();","sourceCodeStart":327,"sourceCodeEnd":363,"githubUrl":"https://github.com/ruvnet/RuView/blob/4685618388a5e49fad5b3005806f3bdd6a7c25c3/harness/ruview/src/guidance.js#L327-L363","documentation":"getGuidance(input, options) requires the second argument, when supplied, to be a non-null, non-array object. The `= {}` default only covers undefined, so an explicitly passed null, array, or primitive throws 'guidance options must be an object' before topic/query validation.","triggerScenarios":"getGuidance({}, null), getGuidance({ topic: 'overview' }, []), or a caller spreading a non-object collection into the options slot, e.g. getGuidance({}, ...extra) where extra is an array.","commonSituations":"Optional-argument threading where a caller passes null to mean 'no options'; forwarding MCP args arrays into the options position; refactors that changed options from a string (e.g. repoRoot) to an object.","solutions":["Omit the second argument entirely when there are no options: getGuidance({ topic: 'overview' }).","Normalize before calling: options = (options === null || Array.isArray(options) || typeof options !== 'object') ? {} : options;","If you previously passed a string repoRoot, migrate to getGuidance(input, { repoRoot })."],"exampleFix":"// before\ngetGuidance({ topic: 'overview' }, null)\n// after\ngetGuidance({ topic: 'overview' }) // or getGuidance({ topic: 'overview' }, {})","handlingStrategy":"type-guard","validationCode":"const options = rawOptions === undefined || rawOptions === null ? {} : rawOptions;\nif (typeof options !== 'object' || Array.isArray(options)) {\n  throw new Error('guidance options must be an object');\n}\ngetGuidance(input, options);","typeGuard":"function isGuidanceOptions(v) {\n  return v === undefined || v === null || (typeof v === 'object' && !Array.isArray(v));\n}","tryCatchPattern":"try {\n  getGuidance(input, options);\n} catch (e) {\n  if (e instanceof TypeError && e.message === 'guidance options must be an object') {\n    return getGuidance(input, {});\n  }\n  throw e;\n}","preventionTips":["Omit the second argument rather than passing null when there are no options.","Keep option bags as plain objects; never arrays or class instances at this boundary.","Encode 'no options' as undefined, matching the API's default."],"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"}