{"record":{"id":"d7f98ba02b47f875","repo":"apache/beam","slug":"initial-splitting-returned-0-restrictions","errorCode":null,"errorMessage":"initial splitting returned 0 restrictions.","messagePattern":"initial splitting returned 0 restrictions\\.","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/core/runtime/exec/sdf.go","lineNumber":1035,"sourceCode":"// because sizing information is unnecessary for unexpanded SDFs.\nfunc (n *SdfFallback) ProcessElement(ctx context.Context, elm *FullValue, values ...ReStream) error {\n\tif n.PDo.status != Active {\n\t\terr := errors.Errorf(\"invalid status %v, want Active\", n.PDo.status)\n\t\treturn errors.WithContextf(err, \"%v\", n)\n\t}\n\n\trest, err := n.initRestInv.Invoke(ctx, elm)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tsplitRests, err := n.splitInv.Invoke(ctx, elm, rest)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif len(splitRests) == 0 {\n\t\terr := errors.Errorf(\"initial splitting returned 0 restrictions.\")\n\t\treturn errors.WithContextf(err, \"%v\", n)\n\t}\n\n\tfor _, splitRest := range splitRests {\n\t\trt, err := n.trackerInv.Invoke(ctx, splitRest)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tmainIn := &MainInput{\n\t\t\tKey:      *elm,\n\t\t\tValues:   values,\n\t\t\tRTracker: rt,\n\t\t}\n\t\tif err := n.PDo.processMainInput(mainIn); err != nil {\n\t\t\treturn err\n\t\t}\n\t}","sourceCodeStart":1017,"sourceCodeEnd":1053,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/runtime/exec/sdf.go#L1017-L1053","documentation":"The initial split function of an unexpanded Splittable DoFn must return at least one restriction. If n.splitInv.Invoke returns an empty slice, the executor cannot create any restriction trackers and fails fast with this error. The error is wrapped with the transform context naming the failing SDF.","triggerScenarios":"A user SDF's SplitRestriction returns an empty slice (e.g. filtering out all candidate restrictions because inputs are empty, out of range, or a default case returns nil). Raised in SdfFallback.ProcessElement at sdf.go:1035 right after initial splitting.","commonSituations":"Custom SplitRestriction implementations that return nil/empty when the element has no data, or that cap split count to a computed value which is 0 for the given input. Also occurs when the restriction doesn't overlap the element's valid range.","solutions":["Make SplitRestriction always return at least one restriction, even a trivial/empty one, for any input.","Check any filtering or count computation in SplitRestriction that can yield zero splits for valid inputs.","Return an error instead of an empty slice when splitting genuinely cannot proceed, to give a clearer failure.","Use the transform name in the error context to find the offending SDF and add a unit test for its SplitRestriction."],"exampleFix":"// before\nfunc (fn *mySdf) SplitRestriction(el string, rest watermarksInterval) []watermarksInterval {\n    if len(el) < 10 { return nil } // 0 restrictions -> runtime error\n    ...\n}\n// after\nfunc (fn *mySdf) SplitRestriction(el string, rest watermarksInterval) []watermarksInterval {\n    if len(el) < 10 { return []watermarksInterval{rest} } // always return at least one\n    ...\n}","handlingStrategy":"validation","validationCode":"splits := fn.SplitRestriction(el, rest)\nif len(splits) == 0 {\n    return fmt.Errorf(\"SplitRestriction returned 0 restrictions for %v\", el)\n}","typeGuard":null,"tryCatchPattern":"if err != nil {\n    if strings.Contains(err.Error(), \"initial splitting returned 0 restrictions\") {\n        // fix SplitRestriction for the transform named in the context\n    }\n    return err\n}","preventionTips":["Always return at least one restriction from SplitRestriction.","Add a unit test asserting non-empty output for representative inputs.","Avoid filter logic that can eliminate all splits."],"tags":["go","beam","sdf","splitting"],"backgroundTag":"empty-result-set","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"}