{"record":{"id":"6ff1e7ad927ea6eb","repo":"plandex-ai/plandex","slug":"error-rejecting-plan-file-v","errorCode":null,"errorMessage":"error rejecting plan file: %v","messagePattern":"error rejecting plan file: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/server/model/plan/build_exec.go","lineNumber":334,"sourceCode":"\n\t\terr := db.ExecRepoOperation(db.ExecRepoOperationParams{\n\t\t\tOrgId:       currentOrgId,\n\t\t\tUserId:      fileState.currentUserId,\n\t\t\tPlanId:      planId,\n\t\t\tBranch:      branch,\n\t\t\tPlanBuildId: build.Id,\n\t\t\tScope:       db.LockScopeWrite,\n\t\t\tReason:      \"reset file op\",\n\t\t\tCtx:         activePlan.Ctx,\n\t\t\tCancelFn:    activePlan.CancelFn,\n\t\t}, func(repo *db.GitRepo) error {\n\t\t\tnow := time.Now()\n\t\t\treturn db.RejectPlanFile(currentOrgId, planId, filePath, now)\n\t\t})\n\n\t\tif err != nil {\n\t\t\tlog.Printf(\"Error rejecting plan file: %v\\n\", err)\n\t\t\tfileState.onBuildFileError(fmt.Errorf(\"error rejecting plan file: %v\", err))\n\t\t\treturn\n\t\t}\n\n\t\tbuildInfo := &shared.BuildInfo{\n\t\t\tPath:      filePath,\n\t\t\tNumTokens: 0,\n\t\t\tFinished:  true,\n\t\t\tRemoved:   fileState.contextPart == nil,\n\t\t}\n\n\t\tactivePlan.Stream(shared.StreamMessage{\n\t\t\tType:      shared.StreamMessageBuildInfo,\n\t\t\tBuildInfo: buildInfo,\n\t\t})\n\n\t\ttime.Sleep(200 * time.Millisecond)\n\n\t\tfileState.onBuildProcessed(activeBuild)","sourceCodeStart":316,"sourceCodeEnd":352,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/server/model/plan/build_exec.go#L316-L352","documentation":"Raised in buildFile when a reset operation for a file cannot be completed. For IsResetOp builds the code runs an ExecRepoOperation (write-locked git repo op) whose callback calls db.RejectPlanFile to reject pending changes for the file. Any failure from the repo operation or the rejection itself is wrapped as 'error rejecting plan file: %v' and sent to onBuildFileError, failing this file's build.","triggerScenarios":"A reset-file build executes and either the write-locked ExecRepoOperation fails (repo lock contention/cancelation, git repo error) or db.RejectPlanFile fails to persist the rejection (DB write error, missing plan file record for the path).","commonSituations":"User clicks 'revert/reset changes' on a plan file whose pending record was already cleared or deleted; concurrent builds/edits hold the repo write lock; database outage or constraint violation during StoreDescription/RejectPlanFile; operation canceled via plan CancelFn mid-reset.","solutions":["Read the wrapped err in the log to see whether it came from the repo lock or from RejectPlanFile","Retry the reset — transient repo-lock contention or cancellation is the most common cause","Confirm the plan file has a pending record to reject; if already rejected, the file may just need a refresh instead of a reset","Check DB connectivity/health if RejectPlanFile persistently fails","Avoid triggering conflicting operations (edit + reset on the same file) simultaneously"],"exampleFix":"// before: two concurrent ops on same file cause lock contention\n// resetOp + build on same path at once\n// after: ensure ops are serialized — wait for the build to finish before issuing reset\nif !activePlan.IsBuildingByPath[filePath] {\n    err := db.ExecRepoOperation(params, func(repo *db.GitRepo) error {\n        return db.RejectPlanFile(currentOrgId, planId, filePath, time.Now())\n    })\n}","handlingStrategy":"retry","validationCode":"if activeBuild.IsResetOp && !activePlan.IsBuildingByPath[filePath] {\n    // safe to issue the reset — no conflicting build in flight\n}","typeGuard":null,"tryCatchPattern":"err := db.ExecRepoOperation(params, func(repo *db.GitRepo) error {\n    return db.RejectPlanFile(orgId, planId, filePath, time.Now())\n})\nif err != nil {\n    if errors.Is(err, context.Canceled) {\n        return // user canceled; do not surface as failure\n    }\n    // retry once on lock contention\n}","preventionTips":["Don't issue reset while a build is active on the same file path","Retry reset operations once on transient lock/cancellation errors","Verify the file has a pending record before resetting","Monitor DB health for RejectPlanFile persistence failures"],"tags":["go","git","database","reset"],"backgroundTag":"repo-operation-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"}