ruvnet/RuView · error · TypeError
guidance topic must be a string
Error message
guidance topic must be a string
What it means
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.
Source
Thrown at harness/homecore/src/guidance.js:60
}
function unique(values) {
return [...new Set(values)];
}
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');View on GitHub (pinned to 4685618388)
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
Defensive patterns
Strategy: try-catch
Validate before calling
def user_record_complete(user: dict) -> bool:
"""The keys the user-info dict construction indexes directly."""
return all(k in user for k in ("username", "email", "roles", "is_active")) Try / catch
try:
user_info = await middleware._authenticate_request(request)
except AuthenticationError as e:
if str(e) == "Token verification failed":
# generic wrapper: real cause is in 'Token verification error' log line
log_and_alert("auth-verification-bug")
raise Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- brain line ${index + 1}: exceeds 16 KiB
- unsupported guidance topic: ${topic}
- guidance query must contain 2..500 characters
- brain line ${index + 1}: ${error.message}
- brain line ${index + 1}: ${errors.join('; ')}
AI-assisted analysis of ruvnet/RuView@4685618388 (2026-08-16).
Data as JSON: /api/errors/243220c526c0116e.
Report an issue: GitHub.