{"record":{"id":"3aaa8358afaca883","repo":"plandex-ai/plandex","slug":"failed-to-stat-map-file-s-v","errorCode":null,"errorMessage":"failed to stat map file %s: %v","messagePattern":"failed to stat map file (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/cli/lib/context_update.go","lineNumber":668,"sourceCode":"\t\t\t\t\t\tvar removed bool\n\n\t\t\t\t\t\tvar hasFileInfo bool\n\t\t\t\t\t\tmu.Lock()\n\t\t\t\t\t\tif _, ok := mapFileInfoByPath[path]; ok {\n\t\t\t\t\t\t\thasFileInfo = true\n\t\t\t\t\t\t} else if _, ok := mapFileRemovedByPath[path]; ok {\n\t\t\t\t\t\t\tremoved = true\n\t\t\t\t\t\t}\n\t\t\t\t\t\tmu.Unlock()\n\n\t\t\t\t\t\tif !(hasFileInfo || removed) {\n\t\t\t\t\t\t\tfileInfo, err := os.Stat(path)\n\t\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\t\tif os.IsNotExist(err) {\n\t\t\t\t\t\t\t\t\tremoved = true\n\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tinnerExistenceErrCh <- fmt.Errorf(\"failed to stat map file %s: %v\", path, err)\n\t\t\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tmu.Lock()\n\t\t\t\t\t\t\tprevTokens := ctx.MapTokens[path]\n\t\t\t\t\t\t\tprevSize := ctx.MapSizes[path]\n\n\t\t\t\t\t\t\tif removed {\n\t\t\t\t\t\t\t\tmapFileRemovedByPath[path] = true\n\t\t\t\t\t\t\t\ttotalMapPaths--\n\t\t\t\t\t\t\t\tif _, existed := ctx.MapShas[path]; existed {\n\t\t\t\t\t\t\t\t\tstate.removedMapPaths = append(state.removedMapPaths, path)\n\t\t\t\t\t\t\t\t\ttokenDiffsById[ctx.Id] -= prevTokens\n\t\t\t\t\t\t\t\t\tstate.totalMapSize -= prevSize\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tmapFileInfoByPath[path] = fileInfo","sourceCodeStart":650,"sourceCodeEnd":686,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/cli/lib/context_update.go#L650-L686","documentation":"Raised while refreshing map (repo-map) contexts: each mapped file is re-statted to detect changes, and an os.Stat error other than NotExist is surfaced here. NotExist is treated as 'removed', so this error means stat failed for a different reason (permissions, I/O, mount issues).","triggerScenarios":"os.Stat(path) on a file recorded in ctx.MapTokens returns an error that is not os.IsNotExist, inside the per-map-file innerExistenceErrCh goroutine.","commonSituations":"File permissions tightened since the map was built; file replaced by a directory or vice versa mid-refresh; NFS/network filesystem returning EIO; antivirus locking the file on Windows.","solutions":["Check the wrapped %v cause and restore read access (chmod/chown) on the mapped file.","If the file moved, remove and rebuild the map context so its file list matches disk.","Re-run the refresh if the file was being modified concurrently by another tool.","For network mounts, verify the mount is healthy before refreshing."],"exampleFix":"// before\n-rw------- locked.go   # stat/permission error in map refresh\n// after\nchmod 644 locked.go","handlingStrategy":"validation","validationCode":"for _, p := range mappedFiles {\n    if _, err := os.Stat(p); err != nil && !os.IsNotExist(err) {\n        return fmt.Errorf(\"mapped file %s not statable: %w\", p, err)\n    }\n}","typeGuard":null,"tryCatchPattern":"if err := refreshMapCtx(ctx); err != nil {\n    if strings.Contains(err.Error(), \"failed to stat map file\") {\n        // restore permissions or rebuild map\n    }\n}","preventionTips":["Keep permissions stable on mapped files (644/755)","Avoid file locks from antivirus/indexers on repo dirs","Rebuild the map after large file moves","Avoid network filesystems for repo maps"],"tags":["filesystem","repo-map","stat"],"backgroundTag":"file-stat-failed","analyzedSha":"e2d772072efadbe41d2946d97d79be55532dbab5","analyzedAt":"2026-09-05T20:56:53.631Z","contentChangedAt":"2026-09-05T20:56:53.631Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}