ruvnet/RuView · error · TypeError

guidance input must be an object

Error message

guidance input must be an object

What it means

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.

Source

Thrown at harness/ruview/src/guidance.js:342

 *   topic: string,
 *   query: string|null,
 *   summary: string,
 *   topics: Array<{topic: string, summary: string}>,
 *   capabilities: Array<object>,
 *   entryPoints: string[],
 *   recommendedCommands: string[],
 *   relatedKnowledge: object[],
 *   sourceCheck: object,
 *   authority: string
 * }} Structured guidance suitable for CLI or MCP serialization.
 * @throws {TypeError|RangeError} When called directly with malformed input.
 *
 * @example
 * getGuidance({ topic: 'homecore', query: 'Wasmtime plugin' });
 */
export function getGuidance(input = {}, options = {}) {
  if (!input || typeof input !== 'object' || Array.isArray(input)) {
    throw new TypeError('guidance input must be an object');
  }
  if (!options || typeof options !== 'object' || Array.isArray(options)) {
    throw new TypeError('guidance options must be an object');
  }
  if (input.topic !== undefined && typeof input.topic !== 'string') {
    throw new TypeError('guidance topic must be a string');
  }
  if (input.query !== undefined && typeof input.query !== 'string') {
    throw new TypeError('guidance query must be a string');
  }
  if (input.limit !== undefined && (typeof input.limit !== 'number' || !Number.isFinite(input.limit))) {
    throw new TypeError('guidance limit must be a finite number');
  }
  if (options.repoRoot !== undefined && options.repoRoot !== null && typeof options.repoRoot !== 'string') {
    throw new TypeError('guidance repoRoot must be a string or null');
  }
  const topic = input.topic === undefined ? 'overview' : input.topic;
  if (!GUIDANCE_TOPICS.includes(topic)) {

View on GitHub (pinned to 4685618388)

Solutions

  1. Call getGuidance({}) or getGuidance({ topic: 'overview' }) with an object literal.
  2. If input comes from JSON or RPC, shape it before calling: if (typeof input !== 'object' || input === null || Array.isArray(input)) input = {};
  3. For positional arrays, map to named fields first (e.g. { topic: args[0], query: args[1] }).

Example fix

// before
getGuidance(mcpParams) // mcpParams is a positional array like ["overview"]
// after
const input = Array.isArray(mcpParams)
  ? { topic: mcpParams[0], query: mcpParams[1] }
  : (mcpParams ?? {});
getGuidance(input);
Defensive patterns

Strategy: type-guard

Validate before calling

const input = rawInput ?? {};
if (typeof input !== 'object' || input === null || Array.isArray(input)) {
  throw new Error(`guidance input must be an object, got ${Array.isArray(input) ? 'array' : typeof input}`);
}
getGuidance(input);

Type guard

function isGuidanceInput(v) {
  return typeof v === 'object' && v !== null && !Array.isArray(v);
}

Try / catch

try {
  getGuidance(input);
} catch (e) {
  if (e instanceof TypeError && e.message === 'guidance input must be an object') {
    // normalize and retry once with a known-good shape
    return getGuidance({});
  }
  throw e;
}

Prevention

When it happens

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

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

Related errors


AI-assisted analysis of ruvnet/RuView@4685618388 (2026-08-16). Data as JSON: /api/errors/d82deaa9359aabd1. Report an issue: GitHub.