{"record":{"id":"97d5a6ff4fea37e1","repo":"plandex-ai/plandex","slug":"no-context-for-path-s","errorCode":null,"errorMessage":"no context for path: %s","messagePattern":"no context for path: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/shared/plan_result_replacements.go","lineNumber":205,"sourceCode":"\t\t\t\t\tlog.Println(updated)\n\t\t\t\t\tlog.Println(\"planRes.Content:\")\n\t\t\t\t\tlog.Println(planRes.Content)\n\t\t\t\t\treturn nil, fmt.Errorf(\"plan updates out of order: %s\", path)\n\t\t\t\t}\n\n\t\t\t\tupdated = planRes.Content\n\t\t\t\tfiles[path] = updated\n\t\t\t\tupdatedAtByPath[path] = planRes.CreatedAt\n\t\t\t\tdelete(removedByPath, path)\n\n\t\t\t\tcontinue\n\t\t\t} else if updated == \"\" {\n\t\t\t\tcontext := planState.ContextsByPath[path]\n\n\t\t\t\tif context == nil {\n\t\t\t\t\t// spew.Dump(planRes)\n\n\t\t\t\t\treturn nil, fmt.Errorf(\"no context for path: %s\", path)\n\t\t\t\t}\n\n\t\t\t\t// log.Println(\"No updated content -- setting to context body\")\n\n\t\t\t\tupdated = context.Body\n\t\t\t\tshas[path] = context.Sha\n\n\t\t\t\t// log.Println(\"setting updated content to context body\")\n\t\t\t\t// log.Println(updated)\n\t\t\t}\n\n\t\t\treplacements := []*Replacement{}\n\t\t\tfoundTarget := false\n\t\t\tfor _, replacement := range planRes.Replacements {\n\t\t\t\tif replacement.Id == replacementId {\n\t\t\t\t\t// log.Println(\"Found target replacement\")\n\t\t\t\t\tfoundTarget = true\n\t\t\t\t\tbreak","sourceCodeStart":187,"sourceCodeEnd":223,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/shared/plan_result_replacements.go#L187-L223","documentation":"When a plan result has no updated content for a path, GetFilesBeforeReplacement falls back to planState.ContextsByPath[path] to reconstruct the file body. This error means neither an updated content nor a stored context (with Sha/Body) exists for that path, so the file's original content cannot be determined.","triggerScenarios":"Calling GetFiles where a plan result references a path but the provided PlanState.ContextsByPath map lacks an entry for that path (nil context).","commonSituations":"Plan state was loaded from a different run/branch than the plan results; contexts were pruned or never recorded (new file created without a context entry, or state truncated by retention).","solutions":["Ensure the PlanState passed to GetFiles is the one produced with these plan results","Verify ContextsByPath is populated for every path referenced by the plan results before calling GetFiles","If the file is intentionally new, seed a context entry (or empty body) for the path","Log/re-dump the plan result and ContextsByPath keys to find the missing path"],"exampleFix":"// before\nfiles, err := GetFiles(planResults, staleState)\n// after\nif planState.ContextsByPath == nil { return nil, fmt.Errorf(\"empty plan state\") }\nfor _, pr := range planResults { if _, ok := planState.ContextsByPath[pr.Path]; !ok { return nil, fmt.Errorf(\"missing context for %s\", pr.Path) } }\nfiles, err := GetFiles(planResults, planState)","handlingStrategy":"validation","validationCode":"func ensureContexts(state shared.PlanState, results []shared.PlanResult) error {\n    for _, r := range results {\n        if state.ContextsByPath[r.Path] == nil {\n            return fmt.Errorf(\"missing context for path %s\", r.Path)\n        }\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":"files, err := GetFiles(results, state)\nif err != nil {\n    var pathErr *pathError\n    if strings.Contains(err.Error(), \"no context for path\") {\n        return fmt.Errorf(\"plan state and results mismatch: %w\", err)\n    }\n    return err\n}","preventionTips":["Always pass the PlanState captured with the same run as the plan results","Seed context entries for newly created files","Verify ContextsByPath keys against result paths before processing"],"tags":["go","plan-results","missing-data","state"],"backgroundTag":"missing-context-for-path","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"}