DIYgod/RSSHub · error · Error
Unable to discover the current Locals feed action id.
Error message
Unable to discover the current Locals feed action id.
What it means
Thrown by `resolveActionIds` (lib/routes/locals/feed.ts:276) when the serverApi JS asset was fetched successfully but `extractFeedActionId(assetContent)` returned null. The action id is extracted from the bundle source; a null result means the regex/anchor used to find it no longer matches the current minified code.
Source
Thrown at lib/routes/locals/feed.ts:277
function fetchContentPage(community: string, session: string) {
return cache.tryGet(`locals:content-page:${community}`, () => ofetch(`${rootUrl}/${community}/feed?mode=content`, { headers: getRequestHeaders(session) }));
}
function resolveActionIds(community: string, session: string) {
return cache.tryGet(`locals:action-ids:${community}`, async () => {
const html = await fetchContentPage(community, session);
const serverApiAsset = extractAssetUrls(html).find((assetUrl) => assetUrl.includes('/serverApi-'));
if (!serverApiAsset) {
throw new Error('Unable to locate the current Locals serverApi asset.');
}
const assetContent = await ofetch(new URL(serverApiAsset, rootUrl).href, {
headers: getRequestHeaders(session),
});
const serverId = extractFeedActionId(assetContent);
if (!serverId) {
throw new Error('Unable to discover the current Locals feed action id.');
}
return serverId;
});
}
function getImage(post: LocalsPost) {
return post.photos?.[0]?.sizes?.full?.url || post.photos?.[0]?.sizes?.thumb?.url || post.previews?.[0]?.url || post.previews?.[0]?.first_frame_url || post.videos?.[0]?.preview || post.audios?.[0]?.preview;
}
function getTitle(post: LocalsPost) {
const textFallback = post.text
?.replaceAll(/<[^>]+>/g, '\n')
.split('\n')
.map((line) => line.trim())
.find(Boolean);
return post.title || post.subtitle || textFallback || post.share_url || 'Locals post';
}View on GitHub (pinned to bed535e087)
Solutions
- Fetch the resolved asset URL directly in a browser and grep its source for the current feed action id pattern.
- Update `extractFeedActionId`'s regex/anchor to the new identifier.
- Cache-bust `locals:action-ids:<community>` after the fix.
- Verify `new URL(serverApiAsset, rootUrl).href` resolves to a `.js` document, not HTML.
Example fix
// before: a single fixed regex inside extractFeedActionId that no longer matches
// after: try several known anchor shapes, fall back to scanning numeric ids
function extractFeedActionId(assetContent: string): string | null {
const patterns = [
/feedActionId["']?\s*[:=]\s*["'](\d+)["']/,
/action["']\s*,\s*id["']\s*[:=]\s*(\d+)/,
/"(\d{6,})"[^}]{0,40}feed/,
];
for (const re of patterns) {
const m = assetContent.match(re);
if (m) return m[1];
}
return null;
} Defensive patterns
Strategy: validation
Validate before calling
function feedActionIdParsable(assetContent: string): boolean {
return extractFeedActionId(assetContent) !== null;
}
if (!feedActionIdParsable(assetContent)) {
throw new TypeError('Locals serverApi bundle changed; feed action id not found');
} Type guard
function isActionId(value: string | null | undefined): value is string {
return typeof value === 'string' && /^\d+$/.test(value);
} Try / catch
try {
return await resolveActionIds(community, session);
} catch (e) {
if (e instanceof Error && /Unable to discover the current Locals feed action id/.test(e.message)) {
await cache.delete('locals:action-ids:' + community);
return await resolveActionIds(community, session);
}
throw e;
} Prevention
- Maintain multiple anchor regexes in `extractFeedActionId`.
- Pin the action-id cache to a short TTL.
- Capture a bundle fixture for regression testing.
When it happens
Trigger: The serverApi bundle is re-minified and the literal `extractFeedActionId` searches for (e.g. an action name or numeric id) is gone or renamed; the wrong asset was selected; the asset body is an error/redirect document rather than JS.
Common situations: Locals ships a new server-api version; bundler reorders identifiers; the asset URL resolved relative to `rootUrl` incorrectly and fetched a fallback page.
Related errors
- Unable to locate the current Locals serverApi asset.
- Unable to decode the Locals server response.
- Unable to resolve the Locals community metadata.
- Unable to extract creator ID
- JavaScript file not found.
AI-assisted analysis of DIYgod/RSSHub@bed535e087 (2026-08-12).
Data as JSON: /api/errors/a647b7838200cae9.
Report an issue: GitHub.