ruvnet/RuView · error · TypeError

guidance limit must be a finite number

Error message

guidance limit must be a finite number

What it means

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.

Source

Thrown at harness/homecore/src/guidance.js:66

export function listGuidanceTopics() {
  return GUIDANCE_TOPICS.map((topic) => ({ topic, summary: TOPIC_SUMMARIES[topic] }));
}

export function getGuidance(input = {}, options = {}) {
  if (!input || typeof input !== 'object' || Array.isArray(input)) {
    throw new TypeError('guidance input must be an object');
  }
  if (!options || typeof options !== 'object' || Array.isArray(options)) {
    throw new TypeError('guidance options must be an object');
  }
  if (input.topic !== undefined && typeof input.topic !== 'string') {
    throw new TypeError('guidance topic must be a string');
  }
  if (input.query !== undefined && typeof input.query !== 'string') {
    throw new TypeError('guidance query must be a string');
  }
  if (input.limit !== undefined && (typeof input.limit !== 'number' || !Number.isFinite(input.limit))) {
    throw new TypeError('guidance limit must be a finite number');
  }
  if (options.repoRoot !== undefined && options.repoRoot !== null && typeof options.repoRoot !== 'string') {
    throw new TypeError('guidance repoRoot must be a string or null');
  }

  const topic = input.topic === undefined ? 'overview' : input.topic;
  if (!GUIDANCE_TOPICS.includes(topic)) {
    throw new RangeError(`unsupported guidance topic: ${topic}`);
  }
  const query = input.query === undefined ? '' : input.query.trim();
  if (query && (query.length < 2 || query.length > 500)) {
    throw new RangeError('guidance query must contain 2..500 characters');
  }
  const rawLimit = input.limit === undefined ? 20 : input.limit;
  if (rawLimit < 1 || rawLimit > 20) {
    throw new RangeError('guidance limit must be between 1 and 20');
  }
  const limit = Math.floor(rawLimit);

View on GitHub (pinned to 4685618388)

Solutions

  1. Pre-check with get_user(username) and return 409 instead of calling register blindly
  2. On the client, catch AuthenticationError with this message and prompt for a different username or switch to login
  3. Make registration idempotent-safe: return the existing profile or a clear conflict instead of an auth error

Example fix

# before
try:
    await auth.register(username, email, password)
except AuthenticationError as e:
    pass  # surfaces as 401 'User already exists'
# after
if auth.user_manager.get_user(username):
    raise HTTPException(status_code=409, detail="User already exists")
await auth.register(username, email, password)
Defensive patterns

Strategy: validation

Validate before calling

def registration_will_succeed(middleware, username: str) -> bool:
    """The register path re-raises create_user's ValueError; check first."""
    return middleware.user_manager.get_user(username) is None

Try / catch

try:
    result = await middleware.register(username, email, password)
except AuthenticationError as e:
    if "already exists" in str(e):
        raise HTTPException(status_code=409, detail=str(e))  # not 401
    raise

Prevention

When it happens

Trigger: 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.

Common situations: User re-registering after a login error though the account exists; frontend not disabling the submit button; API consumers treating register as idempotent.

Related errors


AI-assisted analysis of ruvnet/RuView@4685618388 (2026-08-16). Data as JSON: /api/errors/5681fadcc518c7d3. Report an issue: GitHub.