{"record":{"id":"4fa8e42f05cc0ea7","repo":"apache/beam","slug":"failed-to-split-at-requested-splits-v-datasource-not","errorCode":null,"errorMessage":"failed to split at requested splits: {%v}, DataSource not initialized","messagePattern":"failed to split at requested splits: (.+?), DataSource not initialized","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/core/runtime/exec/datasource.go","lineNumber":554,"sourceCode":"}\n\n// Split takes a sorted set of potential split indices and a fraction of the\n// remainder to split at, selects and actuates a split on an appropriate split\n// index, and returns the selected split index in a SplitResult if successful or\n// an error when unsuccessful.\n//\n// If the following transform is splittable, and the split indices and fraction\n// allow for splitting on the currently processing element, then a sub-element\n// split is performed, and the appropriate information is returned in the\n// SplitResult.\n//\n// The bufSize param specifies the estimated number of elements that will be\n// sent to this DataSource, and is used to be able to perform accurate splits\n// even if the DataSource has not yet received all its elements. A bufSize of\n// 0 or less indicates that it's unknown, and so uses the current known size.\nfunc (n *DataSource) Split(ctx context.Context, splits []int64, frac float64, bufSize int64) (SplitResult, error) {\n\tif n == nil {\n\t\treturn SplitResult{}, fmt.Errorf(\"failed to split at requested splits: {%v}, DataSource not initialized\", splits)\n\t}\n\tif frac > 1.0 {\n\t\tfrac = 1.0\n\t} else if frac < 0.0 {\n\t\tfrac = 0.0\n\t}\n\n\tn.mu.Lock()\n\tdefer n.mu.Unlock()\n\n\tvar currProg float64 // Current element progress.\n\tvar su SplittableUnit\n\tif n.index < 0 { // Progress is at the end of the non-existant -1st element.\n\t\tcurrProg = 1.0\n\t} else if n.su == nil { // If this isn't sub-element splittable, estimate some progress.\n\t\tcurrProg = 0.5\n\t} else { // If this is sub-element splittable, get progress of the current element.\n","sourceCodeStart":536,"sourceCodeEnd":572,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/runtime/exec/datasource.go#L536-L572","documentation":"DataSource.Split performs dynamic work rebalancing (liquid sharding). If the DataSource pointer itself is nil, there is no source to split, so Beam returns this error including the requested split indices. It is an internal precondition violation: splitting is requested against an uninitialized source.","triggerScenarios":"Calling Split (directly or via the runner's split handler) on a nil *DataSource, typically when bundle/source initialization failed or the source was never started before a split request arrived.","commonSituations":"Runner sends a split request before the DataSource is initialized or after teardown; custom runners driving exec.DataSource manually without calling Start; race between initialization failure and split RPC.","solutions":["Ensure the DataSource is initialized (constructed and started) before handling split requests.","Check worker logs for earlier initialization errors that left the source nil.","Guard runner-side split handling: skip or defer splits until the source reports readiness.","Upgrade/verify the Beam Go SDK version for known split-during-startup races."],"exampleFix":"// before\nres, err := source.Split(ctx, splits, frac, bufSize)\n// after\nif source == nil {\n    return SplitResult{}, nil // or retry after initialization\n}\nres, err := source.Split(ctx, splits, frac, bufSize)","handlingStrategy":"type-guard","validationCode":"if source == nil { return SplitResult{}, errors.New(\"source not initialized; cannot split\") }","typeGuard":"func splitable(n *exec.DataSource) bool { return n != nil }","tryCatchPattern":"res, err := source.Split(ctx, splits, frac, bufSize)\nif err != nil && strings.Contains(err.Error(), \"DataSource not initialized\") {\n    return handleUninitializedSource(ctx)\n}","preventionTips":["Always initialize/start the DataSource before serving split requests","Check worker logs for earlier init failures that nil the source","Queue split RPCs until the source reports readiness"],"tags":["beam-go","split","nil-check","datasource"],"backgroundTag":"null-argument","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"}