jackwener/OpenCLI · warning · EmptyResultError

lesswrong comments: Post "${postId}" not found

Error message

lesswrong comments: Post "${postId}" not found

What it means

The lesswrong comments command first resolves the post by ID via GraphQL; when postData.post.result lacks _id, it throws EmptyResultError saying the post was not found. The post ID (or post URL) supplied did not match an existing post.

Source

Thrown at clis/lesswrong/comments.js:41

    func: async (kwargs) => {
        const postId = gqlEscape(parsePostId(String(kwargs['url-or-id'])));
        const limit = Number(kwargs.limit ?? 5);
        // Fetch post title and comments in parallel
        const [postData, commentsData] = await Promise.all([
            gqlRequest(`query PostTitle {
        post(input: {selector: {documentId: "${postId}"}}) {
          result { _id title slug }
        }
      }`),
            gqlRequest(`query Comments {
        comments(input: {terms: {view: "postCommentsTop", postId: "${postId}", limit: ${limit}}}) {
          results { _id user { displayName } baseScore htmlBody postedAt }
        }
      }`),
        ]);
        const post = postData?.post?.result;
        if (!post?._id) {
            throw new EmptyResultError('lesswrong comments', `Post "${postId}" not found`);
        }
        const comments = (commentsData?.comments?.results ?? []);
        const rows = [];
        // First row: post context
        rows.push({
            rank: '',
            score: '',
            author: '',
            text: `Comments on: ${post.title ?? 'Untitled'} (https://${DOMAIN}/posts/${post._id}/${post.slug})`,
        });
        for (let i = 0; i < comments.length; i++) {
            const item = comments[i];
            const user = item.user;
            const raw = stripHtml(item.htmlBody ?? '');
            rows.push({
                rank: i + 1,
                score: item.baseScore ?? 0,
                author: user?.displayName ?? '',

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Re-copy the full post ID or URL and let parsePostId normalize it
  2. Verify the post loads at lesswrong.com/posts/<id>
  3. If using a comment URL, extract the parent post ID instead
  4. Retry in case of transient GraphQL nulls (rare)

Example fix

// before
await lesswrongComments('2025/jan/my-post');
// after
await lesswrongComments('https://www.lesswrong.com/posts/ABcd1234/post-slug'); // full post URL or raw ID
Defensive patterns

Strategy: validation

Validate before calling

// use parsePostId with full URLs; validate shape before calling
const postId = parsePostId(input);
if (!/^[A-Za-z0-9]{6,}$/.test(postId)) throw new Error('not a valid LessWrong post id');

Type guard

const postExists = (d) => typeof d?.post?.result?._id === 'string';

Try / catch

try {
  await lesswrongComments(postId);
} catch (e) {
  if (String(e.message).includes('not found')) console.error(`Post ${postId} missing — verify the URL`);
  else throw e;
}

Prevention

When it happens

Trigger: Calling comments with a postId that doesn't exist, a comment ID mistaken for a post ID, a truncated/URL-encoded ID, or GraphQL returning null for a private/deleted post.

Common situations: Copying a comment permalink and extracting the wrong ID; post deleted or set to draft; URL shortener output used raw; typo when hand-copying the ID.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


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