{"record":{"id":"bbf2c5d49fa1bf87","repo":"ruvnet/RuView","slug":"guidance-limit-must-be-a-finite-number-bbf2c5","errorCode":null,"errorMessage":"guidance limit must be a finite number","messagePattern":"guidance limit must be a finite number","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"harness/ruview/src/guidance.js","lineNumber":354,"sourceCode":" *\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();\n  if (query && (query.length < 2 || query.length > 500)) {\n    throw new RangeError('guidance query must contain 2..500 characters');\n  }\n  const rawLimit = input.limit === undefined ? 20 : input.limit;\n  if (!Number.isFinite(rawLimit) || rawLimit < 1 || rawLimit > 20) {\n    throw new RangeError('guidance limit must be between 1 and 20');\n  }\n  const limit = Math.floor(rawLimit);\n  const wanted = tokenize(query);","sourceCodeStart":336,"sourceCodeEnd":372,"githubUrl":"https://github.com/ruvnet/RuView/blob/4685618388a5e49fad5b3005806f3bdd6a7c25c3/harness/ruview/src/guidance.js#L336-L372","documentation":"getGuidance() requires input.limit, when present, to be a finite JavaScript number. Strings like '10', NaN, Infinity, -Infinity, and null (null is not undefined) all fail this TypeError; the later RangeError covers numeric values outside 1..20.","triggerScenarios":"getGuidance({ limit: '10' }), getGuidance({ limit: NaN }), getGuidance({ limit: Infinity }), getGuidance({ limit: null }); typically from CLI args (always strings) or JSON where the producer serialized the number as a string.","commonSituations":"CLI parsing with yargs/meow without .number('limit'); JSON configs written by hand with quoted numbers; NaN leaking from a division the caller assumed was guarded.","solutions":["Pass a plain number: getGuidance({ limit: 10 }).","Coerce CLI strings: const limit = Number.parseInt(rawLimit, 10); then check Number.isFinite(limit) before calling.","Omit limit entirely to accept the default of 20."],"exampleFix":"// before\ngetGuidance({ limit: cliFlags.limit }) // cliFlags.limit === '10' (string)\n// after\nconst limit = Number.parseInt(cliFlags.limit, 10);\ngetGuidance({ limit: Number.isFinite(limit) ? limit : undefined }); // undefined -> default 20","handlingStrategy":"validation","validationCode":"const limit = rawLimit === undefined ? undefined : Number(rawLimit);\nif (limit !== undefined && !Number.isFinite(limit)) {\n  throw new Error(`limit must be a finite number, got ${String(rawLimit)}`);\n}\ngetGuidance({ limit });","typeGuard":"function isFiniteOptionalNumber(v) {\n  return v === undefined || (typeof v === 'number' && Number.isFinite(v));\n}","tryCatchPattern":"try {\n  getGuidance({ limit });\n} catch (e) {\n  if (e instanceof TypeError && e.message === 'guidance limit must be a finite number') {\n    return getGuidance({ limit: 20 });\n  }\n  throw e;\n}","preventionTips":["Parse CLI/env limits with Number() and check Number.isFinite before calling.","Do not quote numbers in JSON configs.","Reject NaN upstream with a clear message instead of letting it reach the API."],"tags":["validation","guidance","typeerror","coercion","ruview-harness"],"backgroundTag":null,"analyzedSha":"4685618388a5e49fad5b3005806f3bdd6a7c25c3","analyzedAt":"2026-08-16T06:09:40.886Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}