{"record":{"id":"85560e7d5a94d9f2","repo":"apache/beam","slug":"invalid-status-for-plan-v-v","errorCode":null,"errorMessage":"invalid status for plan %v: %v","messagePattern":"invalid status for plan (.+?): (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/core/runtime/exec/plan.go","lineNumber":137,"sourceCode":"// Execute executes the plan with the given data context and bundle id. Units\n// are brought up on the first execution. If a bundle fails, the plan cannot\n// be reused for further bundles. Does not panic. Blocking.\nfunc (p *Plan) Execute(ctx context.Context, id string, manager DataContext) error {\n\tif p.getStatus() == Initializing {\n\t\tfor _, u := range p.units {\n\t\t\tif err := callNoPanic(ctx, u.Up); err != nil {\n\t\t\t\tp.setStatus(Broken)\n\t\t\t\treturn errors.Wrapf(err, \"while executing Up for %v\", p)\n\t\t\t}\n\t\t}\n\t\tp.setStatus(Up)\n\t}\n\tif p.source != nil {\n\t\tp.source.InitSplittable()\n\t}\n\n\tif s := p.getStatus(); s != Up {\n\t\treturn errors.Errorf(\"invalid status for plan %v: %v\", p.id, s)\n\t}\n\n\t// Process bundle. If there are any kinds of failures, we bail and mark the plan broken.\n\n\tp.setStatus(Active)\n\tfor _, root := range p.roots {\n\t\tif err := callNoPanic(ctx, func(ctx context.Context) error { return root.StartBundle(ctx, id, manager) }); err != nil {\n\t\t\tp.setStatus(Broken)\n\t\t\treturn errors.Wrapf(err, \"while executing StartBundle for %v\", p)\n\t\t}\n\t}\n\tfor _, root := range p.roots {\n\t\tif err := callNoPanic(ctx, func(ctx context.Context) error {\n\t\t\tcps, err := root.Process(ctx)\n\t\t\tp.checkpoints = cps\n\t\t\treturn err\n\t\t}); err != nil {\n\t\t\tp.setStatus(Broken)","sourceCodeStart":119,"sourceCodeEnd":155,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/runtime/exec/plan.go#L119-L155","documentation":"After performing Up and initializing splittable sources, Plan.Execute requires plan status Up before processing a bundle. This error means Execute was called on a plan that is not in the Up state - typically a plan that already ran (Active/Broken) or was never reset. The library enforces one bundle lifecycle per status transition; after execution the plan is Active and later Broken, never re-usable.","triggerScenarios":"Calling Plan.Execute twice on the same plan for consecutive bundles; calling Execute on a Broken plan after a previous bundle failure; caching and reusing plans in a runner loop.","commonSituations":"Runner worker loops that keep a plan object around between bundles; test code executing the same plan for multiple test cases; resuming from a checkpoint without constructing a new plan.","solutions":["Construct a new Plan (via NewPlan/constructAndExecutePlan) for every bundle instead of reusing a previously executed plan.","Do not call Execute on a plan that previously returned an error - it is Broken and terminal.","If resuming SDF bundles, the split plan creation path (createSdfPlan) already builds a fresh plan; use that flow."],"exampleFix":"// before\nplan.Execute(ctx, bundle1, mgr)\nplan.Execute(ctx, bundle2, mgr) // invalid status: not Up\n// after\nfor _, bundle := range bundles {\n    plan, err := constructAndExecutePlanWithContext(ctx, planID, units, bundle, mgr)\n    if err != nil { return err }\n}","handlingStrategy":"validation","validationCode":"// Plans are single-use per bundle lifecycle: always build a fresh plan.\nplan, err := constructAndExecutePlanWithContext(ctx, planID, units, bundleID, mgr)\nif err != nil {\n    return err\n}","typeGuard":null,"tryCatchPattern":"if err := plan.Execute(ctx, id, mgr); err != nil {\n    if strings.Contains(err.Error(), \"invalid status for plan\") {\n        plan, err = constructAndExecutePlanWithContext(ctx, id, units, id, mgr)\n    }\n    return err\n}","preventionTips":["Never call Execute twice on the same Plan; construct a new plan per bundle.","Do not retry Execute after errors - the plan status is Broken.","Use the runner's constructAndExecutePlan helper which builds plans per bundle."],"tags":["go","apache-beam","lifecycle","state-machine"],"backgroundTag":"invalid-state-transition","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}