{"record":{"id":"4840d525f2e18be9","repo":"plandex-ai/plandex","slug":"error-reading-projectid-file-s","errorCode":null,"errorMessage":"error reading projectId file: %s","messagePattern":"error reading projectId file: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/cli/fs/projects.go","lineNumber":24,"sourceCode":"\t\"fmt\"\n\t\"os\"\n\t\"path/filepath\"\n\t\"plandex-cli/term\"\n\t\"plandex-cli/types\"\n\t\"strings\"\n)\n\nfunc GetParentProjectIdsWithPaths(currentUserId string) ([][2]string, error) {\n\tvar parentProjectIds [][2]string\n\tcurrentDir := filepath.Dir(Cwd)\n\n\tfor currentDir != \"/\" {\n\t\tplandexDir := findPlandex(currentDir)\n\t\tprojectSettingsPath := filepath.Join(plandexDir, \"projects-v2.json\")\n\t\tif _, err := os.Stat(projectSettingsPath); err == nil {\n\t\t\tbytes, err := os.ReadFile(projectSettingsPath)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"error reading projectId file: %s\", err)\n\t\t\t}\n\n\t\t\tvar settingsByAccount types.CurrentProjectSettingsByAccount\n\t\t\terr = json.Unmarshal(bytes, &settingsByAccount)\n\n\t\t\tif err != nil {\n\t\t\t\tterm.OutputErrorAndExit(\"error unmarshalling projects-v2.json: %v\", err)\n\t\t\t}\n\n\t\t\tsettings := settingsByAccount[currentUserId]\n\n\t\t\tif settings == nil {\n\t\t\t\treturn parentProjectIds, nil\n\t\t\t}\n\n\t\t\tprojectId := string(settings.Id)\n\t\t\tparentProjectIds = append(parentProjectIds, [2]string{currentDir, projectId})\n\t\t}","sourceCodeStart":6,"sourceCodeEnd":42,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/cli/fs/projects.go#L6-L42","documentation":"Fires in GetParentProjectIdsWithPaths when os.ReadFile fails on projects-v2.json inside a discovered .plandex directory while walking up from the current dir. The settings file exists (os.Stat succeeded) but is unreadable — permissions or a race with deletion.","triggerScenarios":"os.ReadFile on an existing projects-v2.json fails — permission denied on the file, it is a directory named projects-v2.json, or an I/O error occurs during read.","commonSituations":"Ancestor .plandex dir created by root or another user with restrictive permissions; corrupted filesystem; projects-v2.json replaced by a directory or a locked file on Windows.","solutions":["Fix permissions on the ancestor .plandex/projects-v2.json (chmod/chown so the current user can read it)","If projects-v2.json is a directory or corrupt, remove or repair it (delete stale ancestor project dirs)","Copy the project to a writable location if on a read-only mount","Identify the exact syscall error from the wrapped %s value"],"exampleFix":"// before\nls -l /parent/.plandex/projects-v2.json  # -rw------- root\n// after\nsudo chown $(whoami) /parent/.plandex/projects-v2.json && chmod 600 /parent/.plandex/projects-v2.json","handlingStrategy":"try-catch","validationCode":"p := filepath.Join(plandexDir, \"projects-v2.json\")\nif f, err := os.Open(p); err != nil {\n    return fmt.Errorf(\"cannot read %s: %w\", p, err)\n} else {\n    f.Close()\n}","typeGuard":null,"tryCatchPattern":"ids, err := GetParentProjectIdsWithPaths(startDir)\nif err != nil {\n    if errors.Is(err, os.ErrPermission) {\n        ids = nil // proceed without ancestor project settings\n    } else {\n        return err\n    }\n}","preventionTips":["Ensure every ancestor .plandex dir is owned/readable by the running user","Delete stale .plandex dirs from abandoned parent projects","Don't create directories named projects-v2.json","Run CLI as the same user that created the projects"],"tags":["filesystem","permissions","config-file"],"backgroundTag":"permission-denied","analyzedSha":"e2d772072efadbe41d2946d97d79be55532dbab5","analyzedAt":"2026-09-05T20:56:53.631Z","contentChangedAt":"2026-09-05T20:56:53.631Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}