upstash/context7 · warning
Library has been redirected
Error message
Library has been redirected
What it means
Warning from `ctx7 docs <library> <query>` (queryCommand): the Context7 API returned ctx.error with a redirectUrl, meaning the requested library ID has been renamed/moved and the old ID no longer serves docs. The command prints the new ID and the exact follow-up command, then sets exitCode=1.
Solutions
- Run the suggested follow-up command with ctx.redirectUrl as the new ID
- Update scripts/bookmarks to the new library ID
- Check context7.com for the library's current ID
Example fix
// before ctx7 docs /old-org/old-lib "how to use hooks" // after ctx7 docs /new-org/new-lib "how to use hooks"
Defensive patterns
Strategy: type-guard
Validate before calling
if (ctx.error && ctx.redirectUrl) { followRedirect(ctx.redirectUrl); return; } Type guard
const isRedirect = (c: ContextResponse): c is ContextResponse & { redirectUrl: string } => !!c.error && typeof c.redirectUrl === 'string'; Try / catch
if (isRedirect(ctx)) { log.info(`New ID: ${ctx.redirectUrl}`); log.info(`Run: ctx7 docs "${ctx.redirectUrl}" "${query}"`); process.exitCode = 1; return; } Prevention
- Pin stable, canonical library IDs in scripts
- Re-validate bookmarked IDs periodically
- Programmatically follow redirectUrl instead of failing
When it happens
Trigger: getLibraryDocs/resolve call returns ContextResponse with error set and redirectUrl present — the library was merged or renamed upstream.
Common situations: Bookmarked or scripted library ID no longer valid after a catalog reorganization; vendor renamed their library.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- No documentation found for
- No libraries found matching
- Your results only include libraries matching your…
- Authentication discovery was redirected. Pass the final…
- await describeErrorResponse(response, fallback)
AI-assisted analysis of upstash/context7@4416fb855b (2026-09-16).
Data as JSON: /api/errors/f606a75e6f29bdd8.
Report an issue: GitHub.
Appendix: source
Thrown at packages/cli/src/commands/docs.ts:158
result = await getLibraryContext(libraryId, query, { type: outputType }, accessToken);
} catch (err) {
spinner?.fail(`Error: ${err instanceof Error ? err.message : String(err)}`);
if (!spinner) log.error(err instanceof Error ? err.message : String(err));
process.exitCode = 1;
return;
}
if (typeof result === "string") {
spinner?.stop();
console.log(result);
return;
}
const ctx = result as ContextResponse;
if (ctx.error) {
if (ctx.redirectUrl) {
spinner?.warn("Library has been redirected");
if (!spinner) log.warn("Library has been redirected");
log.info(`New ID: ${pc.cyan(ctx.redirectUrl)}`);
log.info(`Run: ${pc.cyan(`ctx7 docs "${ctx.redirectUrl}" "${query}"`)}`);
process.exitCode = 1;
return;
}
spinner?.fail(ctx.message || ctx.error);
if (!spinner) log.error(ctx.message || ctx.error);
process.exitCode = 1;
return;
}
const total = (ctx.codeSnippets?.length || 0) + (ctx.infoSnippets?.length || 0);
if (total === 0) {
spinner?.warn(`No documentation found for: "${query}"`);
if (!spinner) log.warn(`No documentation found for: "${query}"`);
return;View on GitHub (pinned to 4416fb855b)