{"record":{"id":"99feaba3773522c4","repo":"ruvnet/RuView","slug":"guidance-input-must-be-an-object","errorCode":null,"errorMessage":"guidance input must be an object","messagePattern":"guidance input must be an object","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"harness/homecore/src/guidance.js","lineNumber":54,"sourceCode":"  for (const term of wanted) {\n    if (idAndName.has(term)) score += 5;\n    else if (topics.has(term)) score += 3;\n    else if (full.has(term)) score += 1;\n  }\n  return score;\n}\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;","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/ruvnet/RuView/blob/4685618388a5e49fad5b3005806f3bdd6a7c25c3/harness/homecore/src/guidance.js#L36-L72","documentation":"Raised at auth.py:270 when the JWT verifies fine but UserManager.get_user(sub) returns None - the username in the sub claim is not in the in-memory self._users dict. UserManager creates no default users and stores nothing persistently, so the store is empty after every process restart.","triggerScenarios":"Server restart: a valid token from before the restart names a user that no longer exists in the fresh empty dict; user was never created via create_user; token issued for a user of another instance/environment; user deleted.","commonSituations":"Dev server auto-reload (uvicorn --reload) wiping registered users mid-session; tokens persisted in a client across server restarts; load-balanced instances where registration happened on instance A but the request hits instance B; assuming seed/admin users exist when the code deliberately provisions none.","solutions":["Re-register the user via create_user / the register endpoint, then log in again to get a token whose sub resolves","If restarts keep losing users, provision users at startup (seed script) or back UserManager with persistent storage","For multi-instance deployments, share the user store or ensure sticky sessions"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"def token_user_exists(token_manager, user_manager, token: str) -> bool:\n    \"\"\"True when the token verifies AND its sub resolves to a stored user.\"\"\"\n    claims = token_manager.decode_token_claims(token)\n    if claims is None:\n        return False\n    return user_manager.get_user(claims.get(\"sub\", \"\")) is not None","typeGuard":null,"tryCatchPattern":"try:\n    user_info = await middleware._authenticate_request(request)\nexcept AuthenticationError as e:\n    if str(e) == \"User not found\":\n        # store was reset or user deleted -> force full re-auth\n        clear_client_token()\n        return json_response({\"error\": \"re-login required\"}, 401)\n    raise","preventionTips":["Persist the user store or seed users at startup","Treat 401 'User not found' as a signal to drop cached tokens","On uvicorn --reload dev flows, expect in-memory users to vanish"],"tags":["auth","user-management","state-loss"],"backgroundTag":null,"analyzedSha":"4685618388a5e49fad5b3005806f3bdd6a7c25c3","analyzedAt":"2026-08-16T06:09:40.886Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}