{"record":{"id":"c549284ab5c01ce1","repo":"jackwener/OpenCLI","slug":"lesswrong-user-string-kwargs-username-check-t","errorCode":null,"errorMessage":"lesswrong user ${String(kwargs.username)}: Check the username — LessWrong slugs are lowercase (e.g. \"zvi\", \"eliezer-yudkowsky\")","messagePattern":"lesswrong user (.+?): Check the username — LessWrong slugs are lowercase \\(e\\.g\\. \"zvi\", \"eliezer-yudkowsky\"\\)","errorType":"error_code","errorClass":"EmptyResultError","httpStatus":null,"severity":"warning","filePath":"clis/lesswrong/user.js","lineNumber":32,"sourceCode":"            name: 'username',\n            type: 'string',\n            required: true,\n            positional: true,\n            help: 'LessWrong username or slug',\n        },\n    ],\n    columns: ['field', 'value'],\n    func: async (kwargs) => {\n        const slug = gqlEscape(String(kwargs.username).toLowerCase());\n        const query = `query UserProfile {\n      user(input: {selector: {slug: \"${slug}\"}}) {\n        result { _id displayName slug bio karma postCount commentCount createdAt }\n      }\n    }`;\n        const data = await gqlRequest(query);\n        const user = data?.user?.result;\n        if (!user?._id) {\n            throw new EmptyResultError(`lesswrong user ${String(kwargs.username)}`, 'Check the username — LessWrong slugs are lowercase (e.g. \"zvi\", \"eliezer-yudkowsky\")');\n        }\n        return [\n            { field: 'Name', value: user.displayName ?? '' },\n            { field: 'Username', value: user.slug ?? '' },\n            { field: 'Karma', value: user.karma ?? 0 },\n            { field: 'Posts', value: user.postCount ?? 0 },\n            { field: 'Comments', value: user.commentCount ?? 0 },\n            { field: 'Joined', value: user.createdAt ?? '' },\n            { field: 'Bio', value: stripHtml(user.bio ?? '') },\n            { field: 'URL', value: `https://${DOMAIN}/users/${user.slug}` },\n        ];\n    },\n});\n","sourceCodeStart":14,"sourceCodeEnd":46,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/lesswrong/user.js#L14-L46","documentation":"lesswrong user queries the GraphQL user endpoint for the given username; when data.user.result has no _id it throws EmptyResultError with the lowercase-slug hint. The username supplied did not resolve to a user profile.","triggerScenarios":"lesswrong user called with a non-slug form (mixed case, spaces, display name), a nonexistent username, or a deleted account, so the GraphQL user lookup returns null result.","commonSituations":"Typing a display name ('Rob Bensinger') instead of the slug ('rob-bensinger'); capitalization ('Raemon' vs 'raemon'); user deactivated their account; typo in the handle.","solutions":["Convert the username to a lowercase hyphenated slug before calling","Confirm the slug from the user's profile URL on lesswrong.com","Check the account still exists and was not renamed or deleted","Retry in case of a transient GraphQL failure"],"exampleFix":"// before\nawait lesswrongUser('Eliezer Yudkowsky');\n// after\nawait lesswrongUser('eliezer-yudkowsky');","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 isUser = (d) => typeof d?.user?.result?._id === 'string';","tryCatchPattern":"try {\n  await lesswrongUser(username);\n} catch (e) {\n  if (e.name === 'EmptyResultError') {\n    return lesswrongUser(username.trim().toLowerCase().replace(/\\s+/g, '-'));\n  }\n  throw e;\n}","preventionTips":["Normalize usernames to slugs before lookup","Take slugs from profile URLs","Check the account is active on lesswrong.com","Retry transient nulls once before failing"],"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"}