{"record":{"id":"3ea168183e1dc781","repo":"apache/beam","slug":"init-not-called","errorCode":null,"errorMessage":"Init() not called","messagePattern":"Init\\(\\) not called","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/core/runtime/exec/input.go","lineNumber":145,"sourceCode":"\treturn ret\n}\n\nfunc (v *iterValue) Init() error {\n\tcur, err := v.s.Open()\n\tif err != nil {\n\t\treturn err\n\t}\n\tv.cur = cur\n\treturn nil\n}\n\nfunc (v *iterValue) Value() any {\n\treturn v.fn\n}\n\nfunc (v *iterValue) Reset() error {\n\tif v.cur == nil {\n\t\tpanic(\"Init() not called\")\n\t}\n\tif err := v.cur.Close(); err != nil {\n\t\treturn err\n\t}\n\tv.cur = nil\n\treturn nil\n}\n\nfunc (v *iterValue) invoke(args []reflect.Value) []reflect.Value {\n\tif v.cur == nil {\n\t\tpanic(\"Init() not called\")\n\t}\n\telm, err := v.cur.Read()\n\tif err != nil {\n\t\tif err == io.EOF {\n\t\t\treturn []reflect.Value{reflect.ValueOf(false)}\n\t\t}\n\t\tpanic(errors.Wrap(err, \"broken stream\"))","sourceCodeStart":127,"sourceCodeEnd":163,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/runtime/exec/input.go#L127-L163","documentation":"This panic is thrown by iterValue.Reset in the Beam Go SDK execution engine when an iterator-typed side input value is Reset or used before Init() has initialized its underlying element stream (v.cur). The library requires the Init lifecycle step to attach a ReStream before iteration or teardown. Resetting an uninitialized value means the plan is being driven out of order.","triggerScenarios":"Calling Reset() on an iterValue whose Init() was never called — typically when the exec plan is invoked without a prior initialization pass, or a custom/modified plan node skips Init on its inputs before cleanup or re-use.","commonSituations":"Hand-constructed or cached execution plans reused across bundles; unit tests that build an iterValue directly and call Reset without Init; engine bugs where a bundle is torn down before inputs were initialized (e.g. after upstream failure).","solutions":["Ensure Init() is called on every ReusableInput before Reset() or iteration (the normal plan lifecycle does this in unit initialization).","Check that the upstream node that provides the ReStream actually executed and did not fail/skip initialization.","If you manage exec plans yourself, guard Reset with a nil check on the underlying stream.","Upgrade the SDK — if this occurs during normal pipeline runs it is an engine lifecycle bug worth reporting."],"exampleFix":"// before\nv := exec.MakeIterValue(...) // direct construction\nv.Reset()\n// after\nv := exec.MakeIterValue(...)\nv.Init(ctx, stream) // initialize before use\nerr := v.Reset()","handlingStrategy":"try-catch","validationCode":"// Go has no pre-call check on unexported state; validate your plan construction instead:\n// ensure every ReusableInput in the plan has Init() called before Reset()/use.","typeGuard":null,"tryCatchPattern":"func safeReset(v interface{ Reset() error }) (err error) {\n\tdefer func() {\n\t\tif r := recover(); r != nil {\n\t\t\tif s, ok := r.(string); ok && s == \"Init() not called\" {\n\t\t\t\terr = fmt.Errorf(\"input used before Init: %v\", r)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tpanic(r)\n\t\t}\n\t}()\n\treturn v.Reset()\n}","preventionTips":["Always run plans through the standard unit initialization lifecycle before processing or cleanup.","Never call Reset on inputs you did not Init in the same lifecycle pass.","In tests, mirror the production init order when constructing exec nodes manually.","Re-initialize cached plans for every bundle instead of reusing live state."],"tags":["go","apache-beam","lifecycle","panic"],"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-20T03:17:13.778Z"}