slidevjs/slidev · error · Error

No content found for slide number ${input.slideNo} in entry:

Error message

No content found for slide number ${input.slideNo} in entry: ${project.entry}. Available slides numbers: 1-${project.data.slides.length}

What it means

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.

Source

Thrown at packages/vscode/src/lmTools.ts:37

      'Entry file': project.entry,
      'Root directory': project.userRoot,
      'Preview server port': project.port.value || 'Not running',
      'Number of slides': project.data.slides.length,
      'Focused slide no. in presentation (from 1)': focusedSlideNo.value || 'None',
      'Editing file': focusedMarkdown.value?.filepath || 'Not editing',
      'Editing slide index in file (from 0)': focusedSourceSlide.value ? focusedSourceSlide.value.index : 'N/A',
    })
  })

  registerSimpleTool('slidev_getSlideContent', (input: {
    entrySlidePath: string
    slideNo: number
  }) => {
    const project = resolveProjectFromEntry(input.entrySlidePath)
    const slide = project.data.slides[input.slideNo - 1]

    if (slide == null) {
      throw new Error(`No content found for slide number ${input.slideNo} in entry: ${project.entry}. Available slides numbers: 1-${project.data.slides.length}`)
    }

    return `Content of slide number ${input.slideNo} in entry "${project.entry}" in file "${slide.source.filepath}":\n\n${stringifySlide(slide.source, 1)}`
  })

  // Get all slide titles
  registerSimpleTool('slidev_getAllSlideTitles', (input: { entrySlidePath: string }) => {
    const project = resolveProjectFromEntry(input.entrySlidePath)
    const titles = project.data.slides.map((slide, idx) => `#${idx + 1}: ${slide.title || '(Untitled)'}`)
    return formatList(titles)
  })

  // Find slide number by title
  registerSimpleTool('slidev_findSlideNoByTitle', (input: { entrySlidePath: string, title: string }) => {
    const project = resolveProjectFromEntry(input.entrySlidePath)
    const idx = project.data.slides.findIndex(slide => slide.title === input.title)
    if (idx === -1) {
      throw new Error(`No slide found with title: "${input.title}".`)

View on GitHub (pinned to 0d798ace58)

Solutions

  1. Use a slide number within `1..N`; call `slidev_getAllSlideTitles` first to learn the exact count and indices.
  2. If the deck was just edited, re-fetch the title list so the slide count is current before retrying.
  3. Validate `slideNo` is an integer ≥ 1 before invoking the tool.

Example fix

// before: model asks for a slide that doesn't exist
{ entrySlidePath: 'slides.md', slideNo: 42 } // deck has 10 slides
// after: discover the real range first
// 1. call slidev_getAllSlideTitles -> learns N=10
// 2. call slidev_getSlideContent with slideNo in 1..10
{ entrySlidePath: 'slides.md', slideNo: 9 }
Defensive patterns

Strategy: validation

Validate before calling

// Validate the 1-based slide number against the live count before calling
// slidev_getSlideContent. Fetch the titles tool first to learn N:
// const titles = await tools.slidev_getAllSlideTitles(...) // gives '#k: title' lines
// const N = titles.length
function isValidSlideNo(no: number, total: number): boolean {
  return Number.isInteger(no) && no >= 1 && no <= total
}

Type guard

function inRange(no: unknown, total: number): no is number {
  return typeof no === 'number' && Number.isInteger(no) && no >= 1 && no <= total
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of slidevjs/slidev@0d798ace58 (2026-08-12). Data as JSON: /api/errors/8b5f47a32dc23482. Report an issue: GitHub.