{"record":{"id":"243220c526c0116e","repo":"ruvnet/RuView","slug":"guidance-topic-must-be-a-string","errorCode":null,"errorMessage":"guidance topic must be a string","messagePattern":"guidance topic must be a string","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"harness/homecore/src/guidance.js","lineNumber":60,"sourceCode":"}\n\nfunction unique(values) {\n  return [...new Set(values)];\n}\n\nexport function listGuidanceTopics() {\n  return GUIDANCE_TOPICS.map((topic) => ({ topic, summary: TOPIC_SUMMARIES[topic] }));\n}\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\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');","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/ruvnet/RuView/blob/4685618388a5e49fad5b3005806f3bdd6a7c25c3/harness/homecore/src/guidance.js#L42-L78","documentation":"The catch-all at auth.py:287 in _authenticate_request: any exception during token verification or user lookup that is not already an AuthenticationError is logged as 'Token verification error: {e}' and re-raised as this generic AuthenticationError. It masks unexpected bugs (KeyError, TypeError, config errors) behind an auth-flavored message.","triggerScenarios":"user['roles'] raising KeyError on a record missing the roles key while building the returned user info; token_blacklist module failing to import inside verify_token; a None token reaching verify_token because split() produced odd input handled elsewhere; settings object missing jwt attributes.","commonSituations":"Corrupted or partial user dicts (roles/email missing); deploying without the src.api.middleware.auth module; version upgrades changing attribute names; production debugging hampered because the true exception is only in logs.","solutions":["Grep the log for 'Token verification error:' and fix the underlying exception it names","Ensure user records always include username, email, roles, is_active before they can be looked up","Reproduce with the exact token and username locally to surface the original traceback"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"def user_record_complete(user: dict) -> bool:\n    \"\"\"The keys the user-info dict construction indexes directly.\"\"\"\n    return all(k in user for k in (\"username\", \"email\", \"roles\", \"is_active\"))","typeGuard":null,"tryCatchPattern":"try:\n    user_info = await middleware._authenticate_request(request)\nexcept AuthenticationError as e:\n    if str(e) == \"Token verification failed\":\n        # generic wrapper: real cause is in 'Token verification error' log line\n        log_and_alert(\"auth-verification-bug\")\n    raise","preventionTips":["Validate user-record shape wherever users enter the store","Log request_id with auth errors to correlate with the root-cause line","Write tests exercising verify+lookup with realistic user dicts"],"tags":["auth","middleware","error-masking"],"backgroundTag":null,"analyzedSha":"4685618388a5e49fad5b3005806f3bdd6a7c25c3","analyzedAt":"2026-08-16T06:09:40.886Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}