{"record":{"id":"58bbaf23311cfcc6","repo":"mastra-ai/mastra","slug":"lesson-lessonname-not-found","errorCode":null,"errorMessage":"Lesson \"${lessonName}\" not found.","messagePattern":"Lesson \"(.+?)\" not found\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/mcp-docs-server/src/tools/course.ts","lineNumber":190,"sourceCode":"      'Content-Type': 'application/json',\n    },\n    body: JSON.stringify({ email }),\n  });\n\n  if (!response.ok) {\n    throw new Error(`Registration failed with status ${response.status}: ${response.statusText}`);\n  }\n\n  return response.json() as Promise<{ success: boolean; id: string; key: string; message: string }>;\n}\n\nasync function readCourseStep(lessonName: string, stepName: string, _isFirstStep: boolean = false): Promise<string> {\n  // Find the lesson directory that matches the name\n  const lessonDirs = await fs.readdir(courseDir);\n  const lessonDir = lessonDirs.find(dir => dir.replace(/^\\d+-/, '') === lessonName);\n\n  if (!lessonDir) {\n    throw new Error(`Lesson \"${lessonName}\" not found.`);\n  }\n\n  // Find the step file that matches the name\n  const lessonPath = path.join(courseDir, lessonDir);\n  const files = await fs.readdir(lessonPath);\n  const stepFile = files.find(f => f.endsWith('.md') && f.replace(/^\\d+-/, '').replace('.md', '') === stepName);\n\n  if (!stepFile) {\n    throw new Error(`Step \"${stepName}\" not found in lesson \"${lessonName}\".`);\n  }\n\n  const filePath = path.join(courseDir, lessonDir, stepFile);\n\n  try {\n    const content = await fs.readFile(filePath, 'utf-8');\n    return wrapContentInPrompt(content);\n  } catch (error) {\n    throw new Error(`Failed to read step \"${stepName}\" in lesson \"${lessonName}\": ${error}`);","sourceCodeStart":172,"sourceCodeEnd":208,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/mcp-docs-server/src/tools/course.ts#L172-L208","documentation":"readCourseStep resolves a lesson name to a directory under the course content dir by stripping the numeric prefix (e.g. `01-intro` -> `intro`). If no directory matches the given lessonName, it throws this error. It means the requested lesson does not exist in the bundled course content.","triggerScenarios":"Calling the course step tool (via stepContent) with a lessonName that does not match any directory in courseDir after prefix stripping — e.g. a typo, wrong casing, or asking for a lesson removed from the course.","commonSituations":"LLM agents hallucinating lesson names; users passing human-readable titles ('Getting Started') instead of slug names ('getting-started'); course content updated between versions so old lesson names no longer exist.","solutions":["List available lessons first (readdir of courseDir, stripping `^\\d+-` prefixes) and use an exact slug match.","Fix typos and match the case of the lesson directory name exactly.","Check for a numeric-prefix mismatch: pass the name without the `01-` prefix, e.g. `intro` not `01-intro`."],"exampleFix":"// before\nawait stepContent({ lessonName: 'Getting Started', stepName: 'overview' });\n// after\nawait stepContent({ lessonName: 'getting-started', stepName: 'overview' });","handlingStrategy":"validation","validationCode":"import { readdirSync } from 'node:fs';\nconst lessons = readdirSync(courseDir).map(d => d.replace(/^\\d+-/, ''));\nif (!lessons.includes(lessonName)) {\n  throw new Error(`Invalid lessonName \"${lessonName}\". Available: ${lessons.join(', ')}`);\n}\nawait stepContent({ lessonName, stepName });","typeGuard":null,"tryCatchPattern":"try {\n  const content = await stepContent({ lessonName, stepName });\n} catch (e) {\n  if (e instanceof Error && e.message.includes('not found.')) {\n    // fall back to listing lessons for the user\n  } else throw e;\n}","preventionTips":["Enumerate lesson slugs before calling and pick from that list, never freeform strings.","Strip numeric prefixes mentally: pass 'intro', not '01-intro'.","Log the available lessons in the error path to aid the caller."],"tags":["not-found","filesystem","input-validation"],"backgroundTag":"resource-not-found","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}