{"record":{"id":"4df6c3ec6d4b37d7","repo":"jackwener/OpenCLI","slug":"lesswrong-comments-post-postid-not-found","errorCode":null,"errorMessage":"lesswrong comments: Post \"${postId}\" not found","messagePattern":"lesswrong comments: Post \"(.+?)\" not found","errorType":"error_code","errorClass":"EmptyResultError","httpStatus":null,"severity":"warning","filePath":"clis/lesswrong/comments.js","lineNumber":41,"sourceCode":"    func: async (kwargs) => {\n        const postId = gqlEscape(parsePostId(String(kwargs['url-or-id'])));\n        const limit = Number(kwargs.limit ?? 5);\n        // Fetch post title and comments in parallel\n        const [postData, commentsData] = await Promise.all([\n            gqlRequest(`query PostTitle {\n        post(input: {selector: {documentId: \"${postId}\"}}) {\n          result { _id title slug }\n        }\n      }`),\n            gqlRequest(`query Comments {\n        comments(input: {terms: {view: \"postCommentsTop\", postId: \"${postId}\", limit: ${limit}}}) {\n          results { _id user { displayName } baseScore htmlBody postedAt }\n        }\n      }`),\n        ]);\n        const post = postData?.post?.result;\n        if (!post?._id) {\n            throw new EmptyResultError('lesswrong comments', `Post \"${postId}\" not found`);\n        }\n        const comments = (commentsData?.comments?.results ?? []);\n        const rows = [];\n        // First row: post context\n        rows.push({\n            rank: '',\n            score: '',\n            author: '',\n            text: `Comments on: ${post.title ?? 'Untitled'} (https://${DOMAIN}/posts/${post._id}/${post.slug})`,\n        });\n        for (let i = 0; i < comments.length; i++) {\n            const item = comments[i];\n            const user = item.user;\n            const raw = stripHtml(item.htmlBody ?? '');\n            rows.push({\n                rank: i + 1,\n                score: item.baseScore ?? 0,\n                author: user?.displayName ?? '',","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/lesswrong/comments.js#L23-L59","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Re-copy the full post ID or URL and let parsePostId normalize it","Verify the post loads at lesswrong.com/posts/<id>","If using a comment URL, extract the parent post ID instead","Retry in case of transient GraphQL nulls (rare)"],"exampleFix":"// before\nawait lesswrongComments('2025/jan/my-post');\n// after\nawait lesswrongComments('https://www.lesswrong.com/posts/ABcd1234/post-slug'); // full post URL or raw ID","handlingStrategy":"validation","validationCode":"// use parsePostId with full URLs; validate shape before calling\nconst postId = parsePostId(input);\nif (!/^[A-Za-z0-9]{6,}$/.test(postId)) throw new Error('not a valid LessWrong post id');","typeGuard":"const postExists = (d) => typeof d?.post?.result?._id === 'string';","tryCatchPattern":"try {\n  await lesswrongComments(postId);\n} catch (e) {\n  if (String(e.message).includes('not found')) console.error(`Post ${postId} missing — verify the URL`);\n  else throw e;\n}","preventionTips":["Pass the full post URL rather than hand-copied IDs","Confirm the post loads in a browser before scripting","Don't confuse comment IDs with post IDs","Handle deleted/unlisted posts gracefully"],"tags":["empty-result","lesswrong","post-id","user-input"],"backgroundTag":"resource-not-found","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}