{"record":{"id":"78371cc1e2e37aac","repo":"d2lang/d2","slug":"s-not-found","errorCode":null,"errorMessage":"\"%s\" not found","messagePattern":"\"(.+?)\" not found","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"d2lsp/d2lsp.go","lineNumber":69,"sourceCode":"\t\t\t}\n\t\t\tif edge.ImportAST() != nil {\n\t\t\t\timportRanges = append(importRanges, edge.ImportAST().GetRange())\n\t\t\t}\n\t\t}\n\t} else {\n\t\tfor _, ref := range f.References {\n\t\t\tranges = append(ranges, ref.AST().GetRange())\n\t\t}\n\t\tif f.ImportAST() != nil {\n\t\t\timportRanges = append(importRanges, f.ImportAST().GetRange())\n\t\t}\n\t}\n\treturn ranges, importRanges, nil\n}\n\nfunc getBoardMap(path string, fs map[string]string, boardPath []string) (*d2ir.Map, error) {\n\tif _, ok := fs[path]; !ok {\n\t\treturn nil, fmt.Errorf(`\"%s\" not found`, path)\n\t}\n\tr := strings.NewReader(fs[path])\n\tast, err := d2parser.Parse(path, r, nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tmfs, err := memfs.New(fs)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tm, _, err := d2ir.Compile(ast, &d2ir.CompileOptions{\n\t\tFS: mfs,\n\t})\n\tif err != nil {\n\t\treturn nil, err\n\t}","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/d2lang/d2/blob/0d69dca6f532ceaeacd615d35d1eaa41a238ffdb/d2lsp/d2lsp.go#L51-L87","documentation":"getBoardMap looks up the requested file path in the provided virtual filesystem map of file contents before parsing. If the path is absent from fs, there is nothing to parse and it returns this error naming the missing path.","triggerScenarios":"Calling d2lsp.GetRefRanges (which calls getBoardMap) with a fs map that lacks an entry for the given path — wrong path key, file never added to the map, or path separator/casing mismatch.","commonSituations":"LSP servers opening a file whose content wasn't loaded into the in-memory map; relative vs absolute path mismatches; stale maps after file renames or deletes.","solutions":["Add the file's content to the fs map under the exact path passed to GetRefRanges","Normalize paths (same separators/casing) used both as map keys and arguments","Ensure the path is the canonical document URI/path your tooling registered"],"exampleFix":"// before\nfs := map[string]string{} // path never added\nranges, _, err := d2lsp.GetRefRanges(key, fs, nil, m)\n// after\nfs := map[string]string{path: docContent}\nranges, _, err := d2lsp.GetRefRanges(key, fs, nil, m)","handlingStrategy":"validation","validationCode":"if _, ok := fs[path]; !ok {\n\treturn fmt.Errorf(\"document %q not loaded\", path)\n}","typeGuard":"func fileLoaded(fs map[string]string, path string) bool {\n\t_, ok := fs[path]\n\treturn ok\n}","tryCatchPattern":"ranges, _, err := d2lsp.GetRefRanges(key, fs, boardPath, m)\nif err != nil && strings.Contains(err.Error(), \"not found\") {\n\treturn fmt.Errorf(\"ensure file %q is open in the workspace\", path)\n}","preventionTips":["Register every open document's content in the fs map before querying","Normalize path separators and casing consistently","Invalidate/update the map on file rename, delete, and change events"],"tags":["d2","lsp","filesystem","missing-file"],"backgroundTag":"file-not-found","analyzedSha":"0d69dca6f532ceaeacd615d35d1eaa41a238ffdb","analyzedAt":"2026-08-31T12:19:21.182Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}