{"record":{"id":"f606a75e6f29bdd8","repo":"upstash/context7","slug":"library-has-been-redirected","errorCode":null,"errorMessage":"Library has been redirected","messagePattern":"Library has been redirected","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/cli/src/commands/docs.ts","lineNumber":158,"sourceCode":"    result = await getLibraryContext(libraryId, query, { type: outputType }, accessToken);\n  } catch (err) {\n    spinner?.fail(`Error: ${err instanceof Error ? err.message : String(err)}`);\n    if (!spinner) log.error(err instanceof Error ? err.message : String(err));\n    process.exitCode = 1;\n    return;\n  }\n\n  if (typeof result === \"string\") {\n    spinner?.stop();\n    console.log(result);\n    return;\n  }\n\n  const ctx = result as ContextResponse;\n\n  if (ctx.error) {\n    if (ctx.redirectUrl) {\n      spinner?.warn(\"Library has been redirected\");\n      if (!spinner) log.warn(\"Library has been redirected\");\n      log.info(`New ID: ${pc.cyan(ctx.redirectUrl)}`);\n      log.info(`Run: ${pc.cyan(`ctx7 docs \"${ctx.redirectUrl}\" \"${query}\"`)}`);\n      process.exitCode = 1;\n      return;\n    }\n\n    spinner?.fail(ctx.message || ctx.error);\n    if (!spinner) log.error(ctx.message || ctx.error);\n    process.exitCode = 1;\n    return;\n  }\n\n  const total = (ctx.codeSnippets?.length || 0) + (ctx.infoSnippets?.length || 0);\n  if (total === 0) {\n    spinner?.warn(`No documentation found for: \"${query}\"`);\n    if (!spinner) log.warn(`No documentation found for: \"${query}\"`);\n    return;","sourceCodeStart":140,"sourceCodeEnd":176,"githubUrl":"https://github.com/upstash/context7/blob/4416fb855b8f752be735e34f943b5d0762701aad/packages/cli/src/commands/docs.ts#L140-L176","documentation":"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.","triggerScenarios":"getLibraryDocs/resolve call returns ContextResponse with error set and redirectUrl present — the library was merged or renamed upstream.","commonSituations":"Bookmarked or scripted library ID no longer valid after a catalog reorganization; vendor renamed their library.","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"],"exampleFix":"// before\nctx7 docs /old-org/old-lib \"how to use hooks\"\n// after\nctx7 docs /new-org/new-lib \"how to use hooks\"","handlingStrategy":"type-guard","validationCode":"if (ctx.error && ctx.redirectUrl) { followRedirect(ctx.redirectUrl); return; }","typeGuard":"const isRedirect = (c: ContextResponse): c is ContextResponse & { redirectUrl: string } => !!c.error && typeof c.redirectUrl === 'string';","tryCatchPattern":"if (isRedirect(ctx)) { log.info(`New ID: ${ctx.redirectUrl}`); log.info(`Run: ctx7 docs \"${ctx.redirectUrl}\" \"${query}\"`); process.exitCode = 1; return; }","preventionTips":["Pin stable, canonical library IDs in scripts","Re-validate bookmarked IDs periodically","Programmatically follow redirectUrl instead of failing"],"tags":["cli","docs","redirect"],"backgroundTag":"resource-not-found","analyzedSha":"4416fb855b8f752be735e34f943b5d0762701aad","analyzedAt":"2026-09-16T20:28:07.148Z","contentChangedAt":"2026-09-16T20:28:07.148Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}