{"record":{"id":"bdad0d530b65d753","repo":"upstash/context7","slug":"no-documentation-found-for-query","errorCode":null,"errorMessage":"No documentation found for: \"${query}\"","messagePattern":"No documentation found for: \"(.+?)\"","errorType":"console","errorClass":null,"httpStatus":null,"severity":"info","filePath":"packages/cli/src/commands/docs.ts","lineNumber":174,"sourceCode":"  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;\n  }\n\n  spinner?.stop();\n\n  if (options.json) {\n    console.log(JSON.stringify(ctx, null, 2));\n    return;\n  }\n\n  log.blank();\n\n  if (ctx.codeSnippets) {\n    for (const snippet of ctx.codeSnippets) {\n      log.plain(pc.bold(snippet.codeTitle));\n      if (snippet.codeDescription) log.dim(snippet.codeDescription);\n      log.blank();","sourceCodeStart":156,"sourceCodeEnd":192,"githubUrl":"https://github.com/upstash/context7/blob/5284672feb575908efead6fcf1b5e542f8d607bb/packages/cli/src/commands/docs.ts#L156-L192","documentation":"Library context was fetched without error, but codeSnippets and infoSnippets are both empty (total === 0), so nothing can be rendered for the query. The spinner branch (line 174) warns; exitCode remains unset — a no-results outcome, not an API failure.","triggerScenarios":"Asking for a topic the library's indexed docs do not cover: overly narrow queries, version-specific features absent from current docs, terminology that does not match the documentation vocabulary, or libraries whose pages contain no extractable snippets.","commonSituations":"Bleeding-edge APIs before documentation catches up; niche/edge-case topics; queries phrased as tasks ('build a login form') instead of doc topics ('authentication').","solutions":["Broaden the query: 'authentication' instead of 'csrf token rotation in edge middleware'","Use the library's own terminology from its official docs","Search the library first (`context7 docs \"<lib>\" search`) to confirm which docs are indexed","Check the docs on context7.com to see whether the topic exists at all"],"exampleFix":"# before\ncontext7 docs \"/websites/nextjs\" \"useTransition underwater basket weaving\"\n\n# after\ncontext7 docs \"/websites/nextjs\" \"useTransition streaming\"","handlingStrategy":"validation","validationCode":"// before scripting against a topic, verify snippets exist\nconst ctx = await fetchContext(library, query);\nconst total = (ctx.codeSnippets?.length || 0) + (ctx.infoSnippets?.length || 0);\nif (total === 0) { console.error(`no coverage for \"${query}\" — broaden terms`); process.exitCode = 1; }","typeGuard":"function hasSnippets(ctx: { codeSnippets?: unknown[]; infoSnippets?: unknown[] }): boolean {\n  return (ctx.codeSnippets?.length ?? 0) + (ctx.infoSnippets?.length ?? 0) > 0;\n}","tryCatchPattern":null,"preventionTips":["Phrase queries as documentation topics, not tasks","Reuse the library docs' own vocabulary","Have a fallback list of broader synonyms when a topic returns nothing"],"tags":["search","no-results","docs","cli"],"backgroundTag":"empty-search-results","analyzedSha":"5284672feb575908efead6fcf1b5e542f8d607bb","analyzedAt":"2026-08-18T18:00:18.510Z","schemaVersion":2},"datasetVersion":"2026-08-24T22:17:12.610Z"}