{"record":{"id":"5681fadcc518c7d3","repo":"ruvnet/RuView","slug":"guidance-limit-must-be-a-finite-number","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/homecore/src/guidance.js","lineNumber":66,"sourceCode":"export 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');\n  }\n  const rawLimit = input.limit === undefined ? 20 : input.limit;\n  if (rawLimit < 1 || rawLimit > 20) {\n    throw new RangeError('guidance limit must be between 1 and 20');\n  }\n  const limit = Math.floor(rawLimit);","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/ruvnet/RuView/blob/4685618388a5e49fad5b3005806f3bdd6a7c25c3/harness/homecore/src/guidance.js#L48-L84","documentation":"The register flow's ValueError handler (auth.py:353) re-raises ValueError from UserManager.create_user - i.e. 'User already exists' - as an AuthenticationError with the same text. So this is the register-endpoint face of the duplicate-username condition; the HTTP layer then maps it to 401 via the AuthenticationError handler unless remapped.","triggerScenarios":"POST register with a username already present in self._users of the running process; client retry of a registration that actually succeeded server-side; concurrent double-submit of the signup form.","commonSituations":"User re-registering after a login error though the account exists; frontend not disabling the submit button; API consumers treating register as idempotent.","solutions":["Pre-check with get_user(username) and return 409 instead of calling register blindly","On the client, catch AuthenticationError with this message and prompt for a different username or switch to login","Make registration idempotent-safe: return the existing profile or a clear conflict instead of an auth error"],"exampleFix":"# before\ntry:\n    await auth.register(username, email, password)\nexcept AuthenticationError as e:\n    pass  # surfaces as 401 'User already exists'\n# after\nif auth.user_manager.get_user(username):\n    raise HTTPException(status_code=409, detail=\"User already exists\")\nawait auth.register(username, email, password)","handlingStrategy":"validation","validationCode":"def registration_will_succeed(middleware, username: str) -> bool:\n    \"\"\"The register path re-raises create_user's ValueError; check first.\"\"\"\n    return middleware.user_manager.get_user(username) is None","typeGuard":null,"tryCatchPattern":"try:\n    result = await middleware.register(username, email, password)\nexcept AuthenticationError as e:\n    if \"already exists\" in str(e):\n        raise HTTPException(status_code=409, detail=str(e))  # not 401\n    raise","preventionTips":["Pre-check get_user() before register calls","Translate 'User already exists' to 409 at the API boundary","Handle double-submit with idempotency keys or disabled buttons"],"tags":["auth","registration","conflict"],"backgroundTag":null,"analyzedSha":"4685618388a5e49fad5b3005806f3bdd6a7c25c3","analyzedAt":"2026-08-16T06:09:40.886Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}