{"record":{"id":"355adae308671178","repo":"plandex-ai/plandex","slug":"error-getting-current-plan-files-v","errorCode":null,"errorMessage":"error getting current plan files: %v","messagePattern":"error getting current plan files: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/server/db/result_helpers.go","lineNumber":301,"sourceCode":"\n\tpendingContextsByPath := map[string]*shared.Context{}\n\tfor path, context := range contextsByPath {\n\t\tpendingContextsByPath[path] = context.ToApi()\n\t}\n\n\t// log.Println(\"Pending contexts by path:\", len(pendingContextsByPath))\n\n\tplanState := &shared.CurrentPlanState{\n\t\tPlanResult:               planResult,\n\t\tConvoMessageDescriptions: convoMessageDescriptions,\n\t\tContextsByPath:           pendingContextsByPath,\n\t\tPlanApplies:              planApplies,\n\t}\n\n\tcurrentPlanFiles, err := planState.GetFiles()\n\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error getting current plan files: %v\", err)\n\t}\n\n\tplanState.CurrentPlanFiles = currentPlanFiles\n\n\treturn planState, nil\n}\n\nfunc GetConvoMessageDescriptions(orgId, planId string) ([]*ConvoMessageDescription, error) {\n\tvar descriptions []*ConvoMessageDescription\n\tdescriptionsDir := getPlanDescriptionsDir(orgId, planId)\n\tfiles, err := os.ReadDir(descriptionsDir)\n\n\tif err != nil {\n\n\t\tif os.IsNotExist(err) {\n\t\t\treturn descriptions, nil\n\t\t}\n","sourceCodeStart":283,"sourceCodeEnd":319,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/server/db/result_helpers.go#L283-L319","documentation":"After the four worker goroutines of GetCurrentPlanState succeed, the assembled planState's GetFiles() method is called to materialize the current plan files. If GetFiles returns an error (e.g. a file result cannot be resolved to concrete file content), it is wrapped as 'error getting current plan files: %v' and returned from GetCurrentPlanState.","triggerScenarios":"Calling GetCurrentPlanState (via invalidateConflictedResults, ClearContext, GetPlanDiffs, etc.) when the assembled CurrentPlanState holds plan file results or applies whose file contents cannot be loaded/merged by planState.GetFiles().","commonSituations":"Plan file results referencing files whose content blobs are missing from storage; corrupted file-result records after a crashed apply; diff/merge failure when combining applied replacements; disk read errors on the underlying file store.","solutions":["Look at the wrapped inner error from GetFiles to see which path or file result failed","Verify the underlying file content for that path exists and is readable in the plan storage","Remove or repair the corrupt plan file result record, then re-run the call","Check for conflicted results (IsPending) that GetFiles cannot resolve and resolve/reject them first","Retry after a transient storage error; the four goroutines have already succeeded, so the failure is isolated to file materialization"],"exampleFix":"// before\nplanState, err := GetCurrentPlanState(params)\nif err != nil {\n    return nil, err\n}\n// after\nplanState, err := GetCurrentPlanState(params)\nif err != nil {\n    if strings.Contains(err.Error(), \"error getting current plan files\") {\n        log.Printf(\"plan files unavailable, using partial state: %v\", err)\n        return planStatePartial(params), nil\n    }\n    return nil, err\n}","handlingStrategy":"fallback","validationCode":"// probe file materialization before the full call\nplanState, err := GetCurrentPlanState(params)\nif err == nil {\n    if _, ferr := planState.GetFiles(); ferr != nil {\n        log.Printf(\"plan files will fail to materialize: %v\", ferr)\n    }\n}","typeGuard":"func isPlanFilesError(err error) bool {\n    return err != nil && strings.Contains(err.Error(), \"error getting current plan files\")\n}","tryCatchPattern":"planState, err := GetCurrentPlanState(params)\nif err != nil {\n    if isPlanFilesError(err) {\n        log.Printf(\"plan files unavailable, using partial state: %v\", err)\n        planState.CurrentPlanFiles = nil\n        return planState, nil\n    }\n    return nil, err\n}","preventionTips":["Resolve or reject pending/conflicted plan file results before loading full state","Verify file content blobs exist in storage for all applied results","Repair records left corrupt by crashed applies","Call GetPlanDiffs/GetFiles early to surface missing-file issues before dependent operations"],"tags":["go","plan-state","filesystem","error-wrapping"],"backgroundTag":"plan-files-materialization-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"}