{"record":{"id":"77afaa89f4342f75","repo":"microsoft/TypeScript","slug":"project-project-getprojectname-does-not-con","errorCode":null,"errorMessage":"Project '${project.getProjectName()}' does not contain document '${fileName}'","messagePattern":"Project '(.+?)' does not contain document '(.+?)'","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/server/utilitiesPublic.ts","lineNumber":65,"sourceCode":"        fileNames: project.getFileNames(/*excludeFilesFromExternalLibraries*/ true, /*excludeConfigFiles*/ true).concat(project.getExcludedFiles() as NormalizedPath[]),\r\n        compilerOptions: project.getCompilationSettings(),\r\n        typeAcquisition,\r\n        unresolvedImports,\r\n        projectRootPath: project.getCurrentDirectory() as Path,\r\n        cachePath,\r\n        kind: \"discover\",\r\n    };\r\n}\r\n\r\nexport namespace Errors {\r\n    export function ThrowNoProject(): never {\r\n        throw new Error(\"No Project.\");\r\n    }\r\n    export function ThrowProjectLanguageServiceDisabled(): never {\r\n        throw new Error(\"The project's language service is disabled.\");\r\n    }\r\n    export function ThrowProjectDoesNotContainDocument(fileName: string, project: Project): never {\r\n        throw new Error(`Project '${project.getProjectName()}' does not contain document '${fileName}'`);\r\n    }\r\n}\r\n\r\nexport type NormalizedPath = string & { __normalizedPathTag: any; };\r\n\r\nexport function toNormalizedPath(fileName: string): NormalizedPath {\r\n    return normalizePath(fileName) as NormalizedPath;\r\n}\r\n\r\nexport function normalizedPathToPath(normalizedPath: NormalizedPath, currentDirectory: string, getCanonicalFileName: (f: string) => string): Path {\r\n    const f = isRootedDiskPath(normalizedPath) ? normalizedPath : getNormalizedAbsolutePath(normalizedPath, currentDirectory);\r\n    return getCanonicalFileName(f) as Path;\r\n}\r\n\r\nexport function asNormalizedPath(fileName: string): NormalizedPath {\r\n    return fileName as NormalizedPath;\r\n}\r\n\r","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/microsoft/TypeScript/blob/b465fdbfe175304d9b977da137b2c178ae1091d3/src/server/utilitiesPublic.ts#L47-L83","documentation":"Thrown via Errors.ThrowProjectDoesNotContainDocument(fileName, project) (utilitiesPublic.ts:65), called from project.ts:1927. It indicates that a request was routed to a specific Project whose script-info set does not contain the requested file — the project and the file are associated incorrectly.","triggerScenarios":"A caller resolves a Project handle (e.g. via a stale config or cross-project lookup) and then asks it for a document it never owned. Common in project.ts paths that assert containment before serving a request; the file may belong to a different project or to no project at all.","commonSituations":"Using a cached/stale project reference after a reload; cross-project operations (e.g. a shared file referenced from two projects) routed to the wrong one; a file that was removed from the project's include; case/path mismatch between the request and the project's internal paths.","solutions":["Re-resolve the owning project via ProjectService.getProjectForFile(fileName) instead of reusing a stale Project handle.","Confirm the fileName (absolute, normalized, correct case) matches a path in project.getFileNames().","If the file was moved/renamed, refresh script-info before retrying.","Handle the case where the file legitimately belongs to a different project and route the request there."],"exampleFix":"// before — using a stale project handle\nconst project = lastKnownProject; // may be wrong after reload\nproject.getLanguageService().getQuickInfoAtPosition(fileName, 0);\n// throws: Project '...' does not contain document '...'\n\n// after — resolve the owning project fresh\nconst project = projectService.getProjectForFile(fileName)\n  ?? Errors.ThrowNoProject();\nproject.getLanguageService().getQuickInfoAtPosition(fileName, 0);","handlingStrategy":"validation","validationCode":"// Re-resolve the owning project and verify containment before routing the request.\nfunction owningProjectForFile(projectService: ProjectService, fileName: string): Project {\n  const project = projectService.getProjectForFile(fileName as NormalizedPath);\n  if (!project || !project.containsFile(fileName as NormalizedPath)) {\n    throw new Error(`${fileName} is not contained by its resolved project; refresh script-info.`);\n  }\n  return project;\n}","typeGuard":"function projectContainsFile(project: Project, fileName: string): boolean {\n  return project.containsFile(fileName as NormalizedPath);\n}","tryCatchPattern":null,"preventionTips":["Always re-resolve the project via getProjectForFile rather than caching handles.","Normalize the fileName (absolute path, correct case) before lookup.","After a reload, refresh script-info before re-issuing requests."],"tags":["server","tsserver","project","script-info","routing"],"backgroundTag":null,"analyzedSha":"b465fdbfe175304d9b977da137b2c178ae1091d3","analyzedAt":"2026-08-12T05:38:42.698Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}