{"record":{"id":"f466c7c31dc49254","repo":"plandex-ai/plandex","slug":"error-creating-temp-dir-v","errorCode":null,"errorMessage":"error creating temp dir: %v","messagePattern":"error creating temp dir: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/server/db/diff_helpers.go","lineNumber":29,"sourceCode":"\n\tshared \"plandex-shared\"\n)\n\nfunc GetPlanDiffs(orgId, planId string, plain bool) (string, error) {\n\tplanState, err := GetCurrentPlanState(CurrentPlanStateParams{\n\t\tOrgId:  orgId,\n\t\tPlanId: planId,\n\t})\n\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"error getting current plan state: %v\", err)\n\t}\n\n\t// create temp directory\n\ttempDirPath, err := os.MkdirTemp(getOrgDir(orgId), \"tmp-diffs-*\")\n\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"error creating temp dir: %v\", err)\n\t}\n\n\tdefer func() {\n\t\tgo os.RemoveAll(tempDirPath)\n\t}()\n\n\t// init a git repo in the temp dir\n\terr = initGitRepo(tempDirPath)\n\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"error initializing git repo: %v\", err)\n\t}\n\n\tfiles := planState.CurrentPlanFiles.Files\n\tremoved := planState.CurrentPlanFiles.Removed\n\n\t// write the original files to the temp dir\n\terrCh := make(chan error, len(planState.ContextsByPath))","sourceCodeStart":11,"sourceCodeEnd":47,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/server/db/diff_helpers.go#L11-L47","documentation":"GetPlanDiffs fails when os.MkdirTemp cannot create a temp directory under the org's data dir while preparing to diff plan versions. Indicates the org directory is missing, unwritable, or the filesystem is out of space/inodes.","triggerScenarios":"os.MkdirTemp(getOrgDir(orgId), \"tmp-diffs-*\") fails because the org directory doesn't exist, the filesystem is full or read-only, or permission bits prevent creation.","commonSituations":"Container images without a writable temp/data volume; org directory never initialized before the first diff; disk-full on the host; running with a restricted user lacking write access to the org dir.","solutions":["Check the wrapped %v error (ENOENT, EACCES, ENOSPC) to identify the filesystem cause","Ensure getOrgDir(orgId) exists — create it with os.MkdirAll before MkdirTemp","Verify the process has write permission on the org directory and the volume is writable","Free disk space if ENOSPC; mount a writable volume in containerized deployments"],"exampleFix":"// before\ntempDirPath, err := os.MkdirTemp(getOrgDir(orgId), \"tmp-diffs-*\")\n// after\norgDir := getOrgDir(orgId)\nif err := os.MkdirAll(orgDir, 0o755); err != nil {\n    return \"\", fmt.Errorf(\"error creating org dir: %v\", err)\n}\ntempDirPath, err := os.MkdirTemp(orgDir, \"tmp-diffs-*\")","handlingStrategy":"validation","validationCode":"orgDir := getOrgDir(orgId)\nif info, err := os.Stat(orgDir); err != nil || !info.IsDir() {\n    if mkErr := os.MkdirAll(orgDir, 0o755); mkErr != nil {\n        return fmt.Errorf(\"org dir not writable: %v\", mkErr)\n    }\n}","typeGuard":null,"tryCatchPattern":"diff, err := db.GetPlanDiffs(orgId, planId, files)\nif err != nil && strings.Contains(err.Error(), \"error creating temp dir\") {\n    log.Printf(\"filesystem problem for org %s: %v — check disk/permissions\", orgId, err)\n    return err\n}","preventionTips":["Create the org directory (os.MkdirAll) at org provisioning time","Mount a writable volume for org data in containers; never use a read-only rootfs","Monitor disk usage (ENOSPC) on the host running diffs","Run the service under a user with write access to the data directory"],"tags":["filesystem","temp-dir","diff","permissions"],"backgroundTag":"temp-dir-creation-failed","analyzedSha":"e2d772072efadbe41d2946d97d79be55532dbab5","analyzedAt":"2026-09-05T20:56:53.631Z","contentChangedAt":"2026-09-05T20:56:53.631Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}