jackwener/OpenCLI · warning · EmptyResultError

Check the username — LessWrong slugs are lowercase (e.g…

Error message

Check the username — LessWrong slugs are lowercase (e.g. "zvi", "eliezer-yudkowsky")

What it means

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.

Solutions

  1. Lowercase the username and replace spaces with hyphens (slug form)
  2. Verify the slug by visiting lesswrong.com/users/<slug> or the profile page URL
  3. Check for typos in the username
  4. If account was renamed/deleted, find the new slug from their posts or search

Example fix

// before
const slug = username; // "Zvi"
// after
const slug = username.trim().toLowerCase().replace(/\s+/g, '-'); // "zvi"
Defensive patterns

Strategy: validation

Validate before calling

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; }

Type guard

const isResolvedUser = (d) => typeof d?._id === 'string' && d._id.length > 0;

Try / catch

try {
  const user = await resolveUserId(rawName);
} catch (e) {
  if (e.name === 'EmptyResultError') {
    const slug = rawName.trim().toLowerCase().replace(/\s+/g, '-');
    return resolveUserId(slug); // retry with slug form
  }
  throw e;
}

Prevention

When it happens

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

Common situations: Passing 'Zvi' instead of 'zvi'; using a display name like 'Eliezer Yudkowsky' instead of 'eliezer-yudkowsky'; typos; deleted or renamed accounts.

Understand the failure class

Background: "User not found", "Invalid user", and "does not exist": what missing-user lookup errors mean across Rocket.Chat, LiteLLM, Phabricator, rustfs, and pnpm — this error's family across 10 libraries.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/d983edb268295486. Report an issue: GitHub.

Appendix: source

Thrown at clis/lesswrong/_helpers.js:66

    }
  }`;
    const data = await gqlRequest(query);
    const tag = data?.tags?.results?.[0];
    if (!tag?._id || !tag?.name)
        return null;
    return { _id: tag._id, name: tag.name };
}
export function resolveUserId(slug) {
    const normalized = gqlEscape(slug.toLowerCase());
    const query = `query UserProfile {
    user(input: {selector: {slug: "${normalized}"}}) {
      result { _id displayName slug }
    }
  }`;
    return gqlRequest(query).then((data) => {
        const user = data?.user?.result;
        if (!user?._id) {
            throw new EmptyResultError(`lesswrong user ${slug}`, 'Check the username — LessWrong slugs are lowercase (e.g. "zvi", "eliezer-yudkowsky")');
        }
        return { _id: user._id, displayName: (user.displayName ?? '') };
    });
}
export function parsePostId(urlOrId) {
    const trimmed = urlOrId.trim();
    const match = trimmed.match(/posts\/([a-zA-Z0-9]+)/);
    return match ? match[1] : trimmed;
}

View on GitHub (pinned to 49907e53dc)