DIYgod/RSSHub · error · Error
Key not found.
Error message
Key not found.
What it means
Thrown when the scoop.sh JS bundle is fetched but the regex for VITE_APP_AZURESEARCH_KEY does not match, so no Azure Search query key can be recovered. Without the key the subsequent POST to the Azure Search index cannot authenticate, so the route aborts.
Source
Thrown at lib/routes/scoop/apps.tsx:62
const targetResponse = await ofetch(targetUrl);
const $: CheerioAPI = load(targetResponse);
const language = $('html').attr('lang') ?? 'en';
const scriptRegExp = /<script type="module" crossorigin src="(.*?)"><\/script>/;
const scriptUrl: string = scriptRegExp.test(targetResponse) ? new URL(targetResponse.match(scriptRegExp)?.[1], baseUrl).href : '';
if (!scriptUrl) {
throw new Error('JavaScript file not found.');
}
const scriptResponse = await ofetch(scriptUrl, {
parseResponse: (txt) => txt,
});
const key: string = scriptResponse.match(/VITE_APP_AZURESEARCH_KEY:"(.*?)"/)?.[1];
if (!key) {
throw new Error('Key not found.');
}
const isOffcial = !query.includes('o=false');
const isDistinct = !query.includes('dm=false');
const sort: string = query.match(/s=(\d+)/)?.[1] ?? '2';
const desc: string = query.match(/d=(\d+)/)?.[1] ?? '1';
const response = await ofetch(apiUrl, {
method: 'post',
query: {
'api-version': '2020-06-30',
},
headers: {
'api-key': key,
origin: baseUrl,
referer: baseUrl,
},
body: {View on GitHub (pinned to bed535e087)
Solutions
- Download the current JS bundle and grep for 'AZURESEARCH' / 'api-key' to find the new identifier.
- Update the regex on line 59 to the new var name/pattern.
- If the key is now fetched at runtime (an XHR to a token endpoint), replicate that request instead of scraping the bundle.
- If scoop.sh stopped exposing a public search key entirely, the route needs a different auth strategy.
Example fix
// before
const key: string = scriptResponse.match(/VITE_APP_AZURESEARCH_KEY:"(.*?)"/)?.[1];
if (!key) {
throw new Error('Key not found.');
}
// after — try several known identifier shapes
const key: string =
scriptResponse.match(/VITE_APP_AZURESEARCH_KEY:"(.*?)"/)?.[1] ||
scriptResponse.match(/VITE_AZURE_SEARCH_KEY:"(.*?)"/)?.[1] ||
scriptResponse.match(/["']?apiKey["']?\s*[:=]\s*["']([A-Za-z0-9]+)["']/)?.[1] ||
'';
if (!key) {
throw new Error('Azure Search key not found in scoop.sh bundle (identifier may have been renamed).');
} Defensive patterns
Strategy: fallback
Validate before calling
// Try several known identifier shapes for the Azure Search key.
function extractAzureKey(bundle: string): string {
return (
bundle.match(/VITE_APP_AZURESEARCH_KEY:"(.*?)"/)?.[1] ||
bundle.match(/VITE_AZURE_SEARCH_KEY:"(.*?)"/)?.[1] ||
bundle.match(/AZURESEARCH_KEY:"(.*?)"/)?.[1] ||
''
);
} Type guard
const looksLikeAzureKey = (k: string | undefined): k is string =>
typeof k === 'string' && /^[A-Za-z0-9+/=]{20,}$/.test(k); Try / catch
let key = extractAzureKey(scriptResponse);
if (!key) {
// re-fetch the bundle (it may have been a stale CDN copy) and retry
const fresh = await ofetch(scriptUrl, { parseResponse: (t) => t });
key = extractAzureKey(fresh);
}
if (!key) throw new Error('Azure Search key not found in scoop.sh bundle (identifier may have been renamed).'); Prevention
- Maintain a list of historical identifier names for the key so renames are tolerated.
- If scoop.sh moves to a runtime-token model, replicate the token request instead of scraping.
- Log the matched identifier so a future rename is self-documenting.
When it happens
Trigger: scriptResponse (the JS bundle text) does not contain the substring VITE_APP_AZURESEARCH_KEY:"..." — the env var was renamed, the bundle is now minified differently, or the key is injected at runtime instead of baked into the bundle.
Common situations: scoop.sh rotated/renamed its Vite env var (e.g. VITE_APP_AZURESEARCH_KEY -> VITE_AZURE_SEARCH_KEY); the build now inlines the key under a different identifier; a sourcemap/deobfuscation change altered the literal.
Related errors
- JavaScript file not found.
- Unable to extract creator ID
- 无法获取最新的 year 和 issue
- Unable to discover the current Locals feed action id.
- Cannot find n-token
AI-assisted analysis of DIYgod/RSSHub@bed535e087 (2026-08-12).
Data as JSON: /api/errors/3c9a94366eb77cb5.
Report an issue: GitHub.