{"record":{"id":"8b5f47a32dc23482","repo":"slidevjs/slidev","slug":"no-content-found-for-slide-number-input-slideno","errorCode":null,"errorMessage":"No content found for slide number ${input.slideNo} in entry: ${project.entry}. Available slides numbers: 1-${project.data.slides.length}","messagePattern":"No content found for slide number (.+?) in entry: (.+?)\\. Available slides numbers: 1-(.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/vscode/src/lmTools.ts","lineNumber":37,"sourceCode":"      'Entry file': project.entry,\n      'Root directory': project.userRoot,\n      'Preview server port': project.port.value || 'Not running',\n      'Number of slides': project.data.slides.length,\n      'Focused slide no. in presentation (from 1)': focusedSlideNo.value || 'None',\n      'Editing file': focusedMarkdown.value?.filepath || 'Not editing',\n      'Editing slide index in file (from 0)': focusedSourceSlide.value ? focusedSourceSlide.value.index : 'N/A',\n    })\n  })\n\n  registerSimpleTool('slidev_getSlideContent', (input: {\n    entrySlidePath: string\n    slideNo: number\n  }) => {\n    const project = resolveProjectFromEntry(input.entrySlidePath)\n    const slide = project.data.slides[input.slideNo - 1]\n\n    if (slide == null) {\n      throw new Error(`No content found for slide number ${input.slideNo} in entry: ${project.entry}. Available slides numbers: 1-${project.data.slides.length}`)\n    }\n\n    return `Content of slide number ${input.slideNo} in entry \"${project.entry}\" in file \"${slide.source.filepath}\":\\n\\n${stringifySlide(slide.source, 1)}`\n  })\n\n  // Get all slide titles\n  registerSimpleTool('slidev_getAllSlideTitles', (input: { entrySlidePath: string }) => {\n    const project = resolveProjectFromEntry(input.entrySlidePath)\n    const titles = project.data.slides.map((slide, idx) => `#${idx + 1}: ${slide.title || '(Untitled)'}`)\n    return formatList(titles)\n  })\n\n  // Find slide number by title\n  registerSimpleTool('slidev_findSlideNoByTitle', (input: { entrySlidePath: string, title: string }) => {\n    const project = resolveProjectFromEntry(input.entrySlidePath)\n    const idx = project.data.slides.findIndex(slide => slide.title === input.title)\n    if (idx === -1) {\n      throw new Error(`No slide found with title: \"${input.title}\".`)","sourceCodeStart":19,"sourceCodeEnd":55,"githubUrl":"https://github.com/slidevjs/slidev/blob/0d798ace5828966d9f77f62094d5f7a971ad98f7/packages/vscode/src/lmTools.ts#L19-L55","documentation":"Thrown by the `slidev_getSlideContent` VS Code LM tool when `project.data.slides[input.slideNo - 1]` is nullish — i.e. the requested 1-based slide number is out of range. The message states the valid range `1-<total>` using the live slide count so the caller can correct the index. The tool converts from 1-based (user-facing) to 0-based array access, so 0 or negative numbers also miss.","triggerScenarios":"The model requests a `slideNo` greater than `project.data.slides.length`, passes 0 or a negative number, or uses a stale count after the deck was edited to have fewer slides. The lookup `slides[input.slideNo - 1]` returns undefined and the guard throws.","commonSituations":"The LM hallucinates a slide count, the deck was edited (slides removed) between the count being read and the content being fetched, or frontmatter separators produce a different slide count than the model expects.","solutions":["Use a slide number within `1..N`; call `slidev_getAllSlideTitles` first to learn the exact count and indices.","If the deck was just edited, re-fetch the title list so the slide count is current before retrying.","Validate `slideNo` is an integer ≥ 1 before invoking the tool."],"exampleFix":"// before: model asks for a slide that doesn't exist\n{ entrySlidePath: 'slides.md', slideNo: 42 } // deck has 10 slides\n// after: discover the real range first\n// 1. call slidev_getAllSlideTitles -> learns N=10\n// 2. call slidev_getSlideContent with slideNo in 1..10\n{ entrySlidePath: 'slides.md', slideNo: 9 }","handlingStrategy":"validation","validationCode":"// Validate the 1-based slide number against the live count before calling\n// slidev_getSlideContent. Fetch the titles tool first to learn N:\n// const titles = await tools.slidev_getAllSlideTitles(...) // gives '#k: title' lines\n// const N = titles.length\nfunction isValidSlideNo(no: number, total: number): boolean {\n  return Number.isInteger(no) && no >= 1 && no <= total\n}","typeGuard":"function inRange(no: unknown, total: number): no is number {\n  return typeof no === 'number' && Number.isInteger(no) && no >= 1 && no <= total\n}","tryCatchPattern":null,"preventionTips":["Always call `slidev_getAllSlideTitles` before `slidev_getSlideContent` to obtain the current slide count.","Treat `slideNo` as 1-based and bounded by the reported count.","Re-fetch the title list after editing the deck, since slide counts can change.","Validate the input is a positive integer before invoking the tool."],"tags":["slidev","vscode","language-model-tools","validation","out-of-range"],"backgroundTag":null,"analyzedSha":"0d798ace5828966d9f77f62094d5f7a971ad98f7","analyzedAt":"2026-08-12T17:10:56.221Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}