{"record":{"id":"d983edb268295486","repo":"jackwener/OpenCLI","slug":"check-the-username-lesswrong-slugs-are-lowercase","errorCode":null,"errorMessage":"Check the username — LessWrong slugs are lowercase (e.g. \"zvi\", \"eliezer-yudkowsky\")","messagePattern":"Check the username — LessWrong slugs are lowercase \\(e\\.g\\. \"zvi\", \"eliezer-yudkowsky\"\\)","errorType":"exception","errorClass":"EmptyResultError","httpStatus":null,"severity":"warning","filePath":"clis/lesswrong/_helpers.js","lineNumber":66,"sourceCode":"    }\n  }`;\n    const data = await gqlRequest(query);\n    const tag = data?.tags?.results?.[0];\n    if (!tag?._id || !tag?.name)\n        return null;\n    return { _id: tag._id, name: tag.name };\n}\nexport function resolveUserId(slug) {\n    const normalized = gqlEscape(slug.toLowerCase());\n    const query = `query UserProfile {\n    user(input: {selector: {slug: \"${normalized}\"}}) {\n      result { _id displayName slug }\n    }\n  }`;\n    return gqlRequest(query).then((data) => {\n        const user = data?.user?.result;\n        if (!user?._id) {\n            throw new EmptyResultError(`lesswrong user ${slug}`, 'Check the username — LessWrong slugs are lowercase (e.g. \"zvi\", \"eliezer-yudkowsky\")');\n        }\n        return { _id: user._id, displayName: (user.displayName ?? '') };\n    });\n}\nexport function parsePostId(urlOrId) {\n    const trimmed = urlOrId.trim();\n    const match = trimmed.match(/posts\\/([a-zA-Z0-9]+)/);\n    return match ? match[1] : trimmed;\n}\n","sourceCodeStart":48,"sourceCodeEnd":76,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/lesswrong/_helpers.js#L48-L76","documentation":"resolveUserId looks up a LessWrong user by slug via GraphQL; if the response has no user._id, it throws EmptyResultError with a hint that LessWrong slugs are lowercase. This means the supplied username did not resolve to any user.","triggerScenarios":"Calling the lesswrong user/resolve flow with a username whose slug does not exist, or with mixed case / spaces / display name instead of the URL slug, so data.user.result comes back null.","commonSituations":"Passing 'Zvi' instead of 'zvi'; using a display name like 'Eliezer Yudkowsky' instead of 'eliezer-yudkowsky'; typos; deleted or renamed accounts.","solutions":["Lowercase the username and replace spaces with hyphens (slug form)","Verify the slug by visiting lesswrong.com/users/<slug> or the profile page URL","Check for typos in the username","If account was renamed/deleted, find the new slug from their posts or search"],"exampleFix":"// before\nconst slug = username; // \"Zvi\"\n// after\nconst slug = username.trim().toLowerCase().replace(/\\s+/g, '-'); // \"zvi\"","handlingStrategy":"validation","validationCode":"function toLwSlug(name){ const s = String(name).trim().toLowerCase().replace(/\\s+/g,'-'); if(!/^[a-z0-9-]+$/.test(s)) throw new Error('invalid LessWrong slug'); return s; }","typeGuard":"const isResolvedUser = (d) => typeof d?._id === 'string' && d._id.length > 0;","tryCatchPattern":"try {\n  const user = await resolveUserId(rawName);\n} catch (e) {\n  if (e.name === 'EmptyResultError') {\n    const slug = rawName.trim().toLowerCase().replace(/\\s+/g, '-');\n    return resolveUserId(slug); // retry with slug form\n  }\n  throw e;\n}","preventionTips":["Always normalize usernames to lowercase-hyphen slugs","Resolve slugs from profile URLs, not display names","Check the account exists on lesswrong.com before lookup","Handle renames by re-searching the display name"],"tags":["user-input","slug","lesswrong","empty-result"],"backgroundTag":"user-not-found","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}