{"record":{"id":"a60ac795d9a200eb","repo":"DIYgod/RSSHub","slug":"no-posts-found-for-the-given-ids","errorCode":null,"errorMessage":"No posts found for the given IDs","messagePattern":"No posts found for the given IDs","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"lib/routes/chikubi/utils.ts","lineNumber":87,"sourceCode":"    const $ = load(description);\n    return $('body')\n        .children()\n        .toArray()\n        .map((el) => $.html(el))\n        .join('');\n}\n\nconst WP_REST_API_URL = 'https://chikubi.jp/wp-json/wp/v2';\n\nexport async function getPosts(ids?: string[]): Promise<DataItem[]> {\n    const url = `${WP_REST_API_URL}/posts${ids?.length ? `?include=${ids.join(',')}` : ''}`;\n\n    const cachedData = await cache.tryGet(url, async () => {\n        const response = await got(url);\n        const data = JSON.parse(response.body);\n\n        if (!Array.isArray(data)) {\n            throw new TypeError('No posts found for the given IDs');\n        }\n\n        return data.map(({ title, link, date, content }) => ({\n            title: title.rendered,\n            link,\n            pubDate: parseDate(date),\n            description: processDescription(content.rendered),\n        }));\n    });\n\n    return ((Array.isArray(cachedData) ? cachedData : []) as Array<DataItem | null>).filter((item): item is DataItem => item !== null);\n}\n\nconst API_TYPES = {\n    tag: 'tags',\n    category: 'categories',\n};\n","sourceCodeStart":69,"sourceCodeEnd":105,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/routes/chikubi/utils.ts#L69-L105","documentation":"Thrown by `getPosts` in chikubi/utils.ts when the WordPress REST API (`/wp-json/wp/v2/posts`) response is not an array. Unusually uses `TypeError` rather than `Error`. WP REST normally returns an array of post objects; a non-array body means WP returned an error object (e.g. `{ code: 'rest_no_route', message: '...' }`) or a 404 HTML page.","triggerScenarios":"One or more of the `include` ids do not exist and WP returns an error envelope instead of an array; the `posts` endpoint is disabled by a security plugin; `got` receives a 404 HTML page and `JSON.parse` still yields an object (not throwing); rate-limiting returns `{ code: 'rest_disabled' }`.","commonSituations":"Passing stale/cached ids that have been deleted, REST API hidden by a hardening plugin (e.g. Wordfence, iThemes Security), or a transient maintenance-page HTML response.","solutions":["Call `https://chikubi.jp/wp-json/wp/v2/posts?include=<ids>` directly in a browser to see the real body.","If the body is an error object, surface `data.message` instead of a generic 'No posts found'.","Drop or correct invalid ids in the `include` list.","Maintainers: consider checking `response.statusCode` and parsing only when 200."],"exampleFix":"// before\nif (!Array.isArray(data)) {\n    throw new TypeError('No posts found for the given IDs');\n}\n// after\nif (!Array.isArray(data)) {\n    throw new Error(`WordPress REST error: ${data?.message ?? 'response was not an array'}`);\n}","handlingStrategy":"validation","validationCode":"const resp = await got(url);\nconst data = JSON.parse(resp.body);\nif (!Array.isArray(data)) {\n    // surface WP error message instead of a generic throw\n    throw new Error(`WP REST: ${data?.message ?? 'non-array response'} (status ${resp.statusCode})`);\n}","typeGuard":"function isPostArray(r: unknown): r is Array<{ id: number; title: { rendered: string }; link: string; date: string; content: { rendered: string } }> {\n    return Array.isArray(r);\n}","tryCatchPattern":null,"preventionTips":["Check `resp.statusCode === 200` before parsing; a 404 HTML page parses to a non-array.","Confirm the WP REST API is not disabled by a security plugin on the source site.","Validate every id in the `include` list exists before batching."],"tags":["upstream-api","response-shape","wordpress-rest","external-service"],"backgroundTag":null,"analyzedSha":"bed535e0879dc71c5aff6f1e7bd1ac21ede40115","analyzedAt":"2026-08-12T19:29:35.364Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}