{"record":{"id":"e4cad7eb163943a2","repo":"ruvnet/RuView","slug":"guidance-limit-must-be-between-1-and-20-e4cad7","errorCode":null,"errorMessage":"guidance limit must be between 1 and 20","messagePattern":"guidance limit must be between 1 and 20","errorType":"validation","errorClass":"RangeError","httpStatus":null,"severity":"error","filePath":"harness/ruview/src/guidance.js","lineNumber":369,"sourceCode":"    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);\n  const candidates = CAPABILITIES\n    .filter((capability) => topic === 'overview' || capability.topics.includes(topic))\n    .map((capability, order) => ({ capability, order, score: scoreCapability(capability, wanted) }))\n    .filter(({ score }) => score > 0)\n    .sort((a, b) => b.score - a.score || a.order - b.order)\n    .slice(0, limit)\n    .map(({ capability }) => ({\n      ...capability,\n      topics: [...capability.topics],\n      sources: [...capability.sources],\n      validation: [...capability.validation],\n      limitations: [...capability.limitations],\n    }));\n\n  const root = options.repoRoot ? resolve(options.repoRoot) : null;","sourceCodeStart":351,"sourceCodeEnd":387,"githubUrl":"https://github.com/ruvnet/RuView/blob/4685618388a5e49fad5b3005806f3bdd6a7c25c3/harness/ruview/src/guidance.js#L351-L387","documentation":"getGuidance clamps result size to 1..20 capabilities. input.limit defaults to 20; values below 1, above 20, or non-finite (NaN/Infinity sneak past the earlier type check only via defaulting) throw this RangeError. Fractional values like 5.5 are floored and accepted.","triggerScenarios":"getGuidance({ limit: 0 }) (often meant as 'default'), { limit: 100 } ('give me everything'), { limit: -1 }; numeric limits parsed from config that also produce NaN via the defaulting path.","commonSituations":"Asking for all capabilities with a large limit; using 0 or -1 as an 'unlimited' sentinel from another API's convention; copying a limit of 50 from a different tool's CLI.","solutions":["Clamp before calling: limit: Math.min(20, Math.max(1, limit)).","Omit limit to accept the default maximum of 20.","If you truly need more coverage, iterate over topics (overview + specific topics) instead of raising the limit."],"exampleFix":"// before\ngetGuidance({ topic: 'overview', limit: 100 }) // RangeError: guidance limit must be between 1 and 20\n// after\nconst limit = Math.min(20, Math.max(1, Number(rawLimit) || 20));\ngetGuidance({ topic: 'overview', limit });","handlingStrategy":"validation","validationCode":"const limit = rawLimit === undefined ? 20 : Math.min(20, Math.max(1, Math.floor(Number(rawLimit))));\nif (!Number.isFinite(limit)) throw new Error('limit must be numeric');\ngetGuidance({ limit });","typeGuard":"function isValidGuidanceLimit(v) {\n  return v === undefined || (typeof v === 'number' && Number.isFinite(v) && v >= 1 && v <= 20);\n}","tryCatchPattern":"try {\n  getGuidance({ limit });\n} catch (e) {\n  if (e instanceof RangeError && e.message.includes('between 1 and 20')) {\n    return getGuidance({ limit: 20 });\n  }\n  throw e;\n}","preventionTips":["Clamp user-supplied limits to 1..20 before calling.","Treat 0/-1 as 'use default (20)', not 'unlimited'.","For broader coverage, iterate topics instead of exceeding the cap."],"tags":["validation","guidance","rangeerror","pagination","ruview-harness"],"backgroundTag":null,"analyzedSha":"4685618388a5e49fad5b3005806f3bdd6a7c25c3","analyzedAt":"2026-08-16T06:09:40.886Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}