{"record":{"id":"5c4f13cc7b746146","repo":"DIYgod/RSSHub","slug":"unable-to-locate-stores-data-for-region-region","errorCode":null,"errorMessage":"Unable to locate stores data for region ${region}","messagePattern":"Unable to locate stores data for region (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"lib/routes/yahoo/news/utils.tsx","lineNumber":126,"sourceCode":"        if (found) {\n            return found;\n        }\n    }\n    return null;\n};\n\nconst getStores = (region) =>\n    cache.tryGet(`yahoo:${region}:stores`, async () => {\n        const { data: response } = await got(`https://${region}.news.yahoo.com/archive`);\n        const $ = load(response);\n\n        const script = $('script:contains(\"pageBenjiConfig\")').text();\n        const rscText = script.match(/self\\.__next_f\\.push\\(\\[1,\"\\d:(.*)\"\\]\\)/)?.[1];\n        const rscData = JSON.parse(JSON.parse(`\"${rscText}\"`));\n\n        const stores = findStoresObject(rscData);\n        if (!stores) {\n            throw new Error(`Unable to locate stores data for region ${region}`);\n        }\n\n        return stores;\n    });\n\nconst parseList = (region, response) =>\n    response.map((item) => ({\n        title: item.title,\n        link: item.canonicalUrl ? item.canonicalUrl.url : item.url.startsWith('http') ? item.url : new URL(item.url, `https://${region}.news.yahoo.com`).href,\n        description: item.summary,\n        pubDate: item.published_at ? parseDate(item.published_at, 'X') : item.pubDate ? parseDate(item.pubDate) : undefined,\n        author: item.provider_name ?? item.provider?.displayName ?? item.publisher,\n    }));\n\nconst parseItem = (item) =>\n    cache.tryGet(item.link, async () => {\n        const { data: response } = await got(item.link, {\n            headers: {","sourceCodeStart":108,"sourceCodeEnd":144,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/routes/yahoo/news/utils.tsx#L108-L144","documentation":"Thrown at lib/routes/yahoo/news/utils.tsx:126 inside getStores when `findStoresObject` cannot locate any object containing a `breakingNews` key within the parsed React Server Components (RSC) payload extracted from the Yahoo News `/archive` page. The RSC data is extracted by regex-matching `self.__next_f.push([1,\"<digits>:<payload>\"])` in a script containing 'pageBenjiConfig', then double-JSON-parsed. If Yahoo changes their Next.js RSC serialization, the page structure, or removes the pageBenjiConfig script, the regex or traversal fails and no stores object is found.","triggerScenarios":"Yahoo News frontend update changes the `self.__next_f.push` serialization format; the `pageBenjiConfig` script is renamed or removed; the regex `/self\\.__next_f\\.push\\(\\[1,\"\\d:(.*)\"\\]\\)/` no longer matches because the push payload structure changed; the `breakingNews` key was renamed in the stores object; the `/archive` page returns a 404 or redirect for a region that no longer exists.","commonSituations":"Yahoo deploys a Next.js version bump altering RSC wire format; a region (hk/tw) archive page is restructured; cached stale page from before the change then a cache miss exposes the breakage.","solutions":["Open `https://{region}.news.yahoo.com/archive` in a browser, view source, and locate the `self.__next_f.push` calls to verify the regex at line 121 still matches.","Update the regex pattern to match the new RSC push format.","Update `findStoresObject` to search for a different landmark key if `breakingNews` was renamed.","Clear cache key `yahoo:{region}:stores` after deploying the fix."],"exampleFix":"// before\nconst rscText = script.match(/self\\.__next_f\\.push\\(\\[1,\"\\d:(.*)\"\\]\\)/)?.[1];\n\n// after (if Next.js changed the push array shape)\nconst rscText = script.match(/self\\.__next_f\\.push\\(\\[1,\"([\\s\\S]*?)\"\\]\\)\\)/)?.[1];","handlingStrategy":"retry","validationCode":null,"typeGuard":"const hasStoresShape = (node: unknown): boolean =>\n    !!node && typeof node === 'object' && 'breakingNews' in node;","tryCatchPattern":"try {\n    const stores = await getStores(region);\n} catch (e) {\n    if (e instanceof Error && e.message.includes('Unable to locate stores data')) {\n        // Yahoo News page structure changed — clear cache and inspect archive HTML\n        await cache.set(`yahoo:${region}:stores`, undefined);\n        console.error('Yahoo News RSC payload structure changed; update getStores extraction');\n    }\n    throw e;\n}","preventionTips":["Periodically verify the regex at line 121 matches the live Yahoo News archive page source.","Make findStoresObject's landmark key configurable or search for multiple known keys.","Clear the yahoo:{region}:stores cache after deploying extraction fixes.","Monitor for Next.js version upgrades on Yahoo News that change RSC serialization."],"tags":["scraping","format-change","parsing","network","yahoo"],"backgroundTag":null,"analyzedSha":"bed535e0879dc71c5aff6f1e7bd1ac21ede40115","analyzedAt":"2026-08-12T19:29:35.364Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}