{"record":{"id":"90b1ff5754b7e5b9","repo":"ruvnet/RuView","slug":"guidance-query-must-contain-2-500-characters-90b1ff","errorCode":null,"errorMessage":"guidance query must contain 2..500 characters","messagePattern":"guidance query must contain 2\\.\\.500 characters","errorType":"validation","errorClass":"RangeError","httpStatus":null,"severity":"error","filePath":"harness/ruview/src/guidance.js","lineNumber":365,"sourceCode":"  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);\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],","sourceCodeStart":347,"sourceCodeEnd":383,"githubUrl":"https://github.com/ruvnet/RuView/blob/4685618388a5e49fad5b3005806f3bdd6a7c25c3/harness/ruview/src/guidance.js#L347-L383","documentation":"When a guidance query is supplied, getGuidance trims it and requires the trimmed length to be between 2 and 500 characters inclusive. An empty/whitespace-only query is treated as 'no query' and passes; a 1-character query or one over 500 characters throws this RangeError.","triggerScenarios":"getGuidance({ query: 'a' }) or { query: ' x' } (trims to 1 char); auto-generated prompts concatenated past 500 chars; passing a long error string or stack trace as the query.","commonSituations":"Single-character/symbol lookups (e.g. 'v2' is fine at 2 chars, 'v' is not); RAG/agent pipelines that stuff whole documents into the query field; copy-pasted multi-paragraph questions exceeding the cap.","solutions":["Trim the query and lengthen or drop it when < 2 chars: const q = raw.trim(); query: q.length >= 2 ? q : undefined.","Truncate long queries to the cap: query: q.slice(0, 500).","For long context, pass a short keyword query and put details elsewhere — guidance is a keyword navigator, not a search engine."],"exampleFix":"// before\ngetGuidance({ topic: 'architecture', query: rawPrompt }) // rawPrompt is 900 chars\n// after\nconst q = rawPrompt.trim().slice(0, 500);\ngetGuidance({ topic: 'architecture', query: q.length >= 2 ? q : undefined });","handlingStrategy":"validation","validationCode":"const q = typeof rawQuery === 'string' ? rawQuery.trim() : '';\nconst query = q.length >= 2 && q.length <= 500 ? q : undefined;\ngetGuidance({ query });","typeGuard":"function isValidGuidanceQuery(v) {\n  if (typeof v !== 'string') return v === undefined;\n  const t = v.trim();\n  return t === '' || (t.length >= 2 && t.length <= 500);\n}","tryCatchPattern":"try {\n  getGuidance({ query });\n} catch (e) {\n  if (e instanceof RangeError && e.message.includes('2..500')) {\n    return getGuidance({ query: undefined }); // drop the bad query\n  }\n  throw e;\n}","preventionTips":["Trim queries at the boundary and treat <2 chars as 'no query'.","Cap user/AI-generated queries with slice(0, 500).","Guide with keywords; guidance scoring is tokenized, so short keyword lists beat long prose."],"tags":["validation","guidance","rangeerror","input-length","ruview-harness"],"backgroundTag":null,"analyzedSha":"4685618388a5e49fad5b3005806f3bdd6a7c25c3","analyzedAt":"2026-08-16T06:09:40.886Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}