jackwener/OpenCLI · warning · EmptyResultError

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

Error message

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

What it means

lesswrong read fetches a single post's data; if data.post.result has no _id the command throws EmptyResultError with the postId embedded. It means the requested post ID did not resolve to a readable post.

Source

Thrown at clis/lesswrong/read.js:32

            name: 'url-or-id',
            type: 'string',
            required: true,
            positional: true,
            help: 'Post URL or LessWrong post ID',
        },
    ],
    columns: ['title', 'author', 'karma', 'comments', 'tags', 'content', 'url'],
    func: async (kwargs) => {
        const postId = parsePostId(String(kwargs['url-or-id']));
        const query = `query PostsSingle {
      post(input: {selector: {documentId: "${gqlEscape(postId)}"}}) {
        result { _id title user { displayName } baseScore commentCount htmlBody slug postedAt tags { name } }
      }
    }`;
        const data = await gqlRequest(query);
        const post = data?.post?.result;
        if (!post?._id) {
            throw new EmptyResultError('lesswrong read', `Post "${postId}" not found`);
        }
        return [
            {
                title: post.title ?? '',
                author: post.user?.displayName ?? '',
                karma: post.baseScore ?? 0,
                comments: post.commentCount ?? 0,
                tags: (post.tags ?? []).map((tag) => tag.name ?? '').filter(Boolean).join(', '),
                content: stripHtml(post.htmlBody ?? ''),
                url: `https://${DOMAIN}/posts/${post._id}/${post.slug}`,
            },
        ];
    },
});

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Verify the ID/URL resolves on lesswrong.com in a browser
  2. Re-copy the post URL and pass the whole URL so parsePostId extracts the ID
  3. Search the post title via lesswrong search to get the current ID
  4. Check for typos or missing characters in the ID

Example fix

// before
await lesswrongRead('4KpDw');
// after
await lesswrongRead('https://www.lesswrong.com/posts/yRBsqzYhXcFvpWvKi/title-slug');
Defensive patterns

Strategy: validation

Validate before calling

const postId = parsePostId(urlOrId); // pass full URL
if (!postId || postId.length < 6) throw new Error('bad post id');

Type guard

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

Try / catch

try {
  await lesswrongRead(postId);
} catch (e) {
  if (String(e.message).includes('not found')) console.error(`Post ${postId} unavailable`);
  else throw e;
}

Prevention

When it happens

Trigger: read invoked with an invalid, deleted, draft, or non-post identifier; parsePostId output from an unrelated URL; GraphQL returned null for that ID.

Common situations: Deleted or unlisted posts; IDs copied from search result snippets that were truncated; confusion between tag/comment IDs and post IDs; old posts migrated to new IDs.

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/88128f229d970ab9. Report an issue: GitHub.