{"record":{"id":"a788b7d1ceb8ed24","repo":"DIYgod/RSSHub","slug":"no-posts-found-a788b7","errorCode":null,"errorMessage":"No posts found","messagePattern":"No posts found","errorType":"exception","errorClass":"Error","httpStatus":503,"severity":"warning","filePath":"lib/routes/toranoana/news.ts","lineNumber":74,"sourceCode":"    if (category) {\n        const categoryResponse = await ofetch(`https://news.toranoana.jp/wp-json/wp/v2/categories?slug=${category}`);\n        if (categoryResponse && categoryResponse.length > 0) {\n            apiUrl += `?categories=${categoryResponse[0].id}`;\n        }\n    } else {\n        // exclude category-joshi to get result of general\n        apiUrl += '?categories_exclude=1598';\n    }\n\n    const posts = await ofetch(apiUrl, {\n        query: {\n            per_page: 20,\n            _embed: 'wp:featuredmedia',\n        },\n    });\n\n    if (!posts || !posts.length) {\n        throw new Error('No posts found');\n    }\n\n    const items = posts.map((post) => {\n        const $ = load(post.content.rendered);\n\n        // remove unnecessary title\n        $('h1').remove();\n        $('h2').first().remove();\n\n        let thumbnail = '';\n        if (post._embedded && post._embedded['wp:featuredmedia'][0].source_url) {\n            thumbnail = post._embedded['wp:featuredmedia'][0].source_url;\n        }\n\n        if (thumbnail) {\n            $('body').prepend(`<img src=\"${thumbnail}\" alt=\"${post.title.rendered}\" />`);\n        }\n","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/routes/toranoana/news.ts#L56-L92","documentation":"Generic Error from the Toranoana news route when the WordPress REST API returns an empty (or falsy) posts array. The handler refuses to emit an empty feed and throws so the caller knows the source yielded nothing.","triggerScenarios":"The ofetch to apiUrl with `per_page:20` and `_embed` returns `[]` or null, so line 73 (`!posts || !posts.length`) is true. Causes: the category filter `?categories_exclude=1598` removes all posts, the endpoint moved, or the site genuinely has no recent posts.","commonSituations":"Wrong/changed category id, upstream WP REST API disabled or returning an HTML error page that ofetch could not parse into an array, or a transient empty state right after a purge.","solutions":["Open the apiUrl in a browser to confirm whether posts are actually returned.","If the categories_exclude id is stale, update it from the current WP taxonomy.","If the API moved, locate the new REST root and update apiUrl.","Retry once — an intermittent empty response may be a cache/CDN hiccup."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"const posts = await ofetch(apiUrl, { query: { per_page: 20, _embed: 'wp:featuredmedia' } });\nif (!Array.isArray(posts) || !posts.length) throw new Error('Toranoana API returned no posts — verify category and endpoint');","typeGuard":"const isPostArray = (v: unknown): v is unknown[] => Array.isArray(v) && v.length > 0;","tryCatchPattern":"try { /* mapping */ }\ncatch (e) { if (e instanceof Error && /No posts/.test(e.message)) { /* return empty feed with clear status instead of crashing */ } else throw e; }","preventionTips":["Keep the WP categories_exclude id in sync with the source","Detect HTML error pages from the REST endpoint","Treat an empty array as a soft 404"],"tags":["wordpress","rest-api","empty-response","toranoana","scraping"],"backgroundTag":null,"analyzedSha":"bed535e0879dc71c5aff6f1e7bd1ac21ede40115","analyzedAt":"2026-08-12T19:29:35.364Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}