apache/beam · error

method %v missing sdf.RTracker, expected one at index %v

Error message

method %v missing sdf.RTracker, expected one at index %v

What it means

The mirror of error 4908: the DoFn was identified as a SplittableDoFn (all required SDF methods present) but ProcessElement lacks an sdf.RTracker parameter before its main inputs. validateIsSdf computes the expected index from ProcessElement's Inputs() and returns this error from AsDoFn.

Source

Thrown at sdks/go/pkg/beam/core/graph/fn.go:884

		isSdf = true
	case len(requiredSdfNames): // No SDF methods.
		isSdf = false
	default: // Anything else means an invalid # of SDF methods.
		err := errors.Errorf("not all required SplittableDoFn methods are present. Missing methods: %v", missing)
		return false, err
	}

	processFn := fn.methods[processElementName]
	if pos, ok := processFn.RTracker(); ok != isSdf {
		if ok {
			err := errors.Errorf("method %v has sdf.RTracker as param %v, expected none",
				processElementName, pos)
			return false, errors.SetTopLevelMsgf(err, "Method %v has an sdf.RTracker parameter at index %v, "+
				"but is not part of a splittable DoFn. sdf.RTracker is invalid in %v in non-splittable DoFns.",
				processElementName, pos, processElementName)
		}
		pos, _, _ = processFn.Inputs()
		err := errors.Errorf("method %v missing sdf.RTracker, expected one at index %v",
			processElementName, pos)
		return false, errors.SetTopLevelMsgf(err, "Method %v is missing an sdf.RTracker "+
			"parameter despite being part of a splittable DoFn. %v in splittable DoFns requires an "+
			"sdf.RTracker parameter before main inputs (in this case, at index %v).",
			processElementName, processElementName, pos)
	}
	return isSdf, nil
}

// validateSdfSignatures validates that types in the SDF methods of a Fn are
// consistent with each other (for example, element and restriction types should
// match with each other). Returns an error if one is found, or nil if the
// types are all valid.
// TODO(BEAM-3301): Once SDF documentation is added to ParDo, add a comment
// here to refer to that for specific details about what needs to be consistent.
func validateSdfSignatures(fn *Fn, numMainIn mainInputs) error {
	num := int(numMainIn)

View on GitHub (pinned to 12126d8942)

Solutions

  1. Add an sdf.RTracker parameter to ProcessElement at the index stated in the error (before main inputs).
  2. Ensure RTracker is positioned before the element/restriction main input parameters.
  3. Return the RTracker from the restriction-creation path so it drives the bundle correctly.

Example fix

// before
func (fn *myFn) ProcessElement(w string, emit func(int)) {}
// SDF methods present

// after
func (fn *myFn) ProcessElement(rt sdf.RTracker, w string, emit func(int)) { ... rt.TryClaim(...) ... }
Defensive patterns

Strategy: validation

Validate before calling

// when all SDF methods exist, confirm ProcessElement starts with sdf.RTracker:
t := reflect.TypeOf(fn)
m, _ := t.MethodByName("ProcessElement")
if isCompleteSdf(fn) && m.Type.In(paramOffset) != reflect.TypeOf((*sdf.RTracker)(nil)).Elem() { /* add RTracker */ }

Type guard

func hasRTrackerFirst(fn interface{}) bool { t := reflect.TypeOf(fn); m, ok := t.MethodByName("ProcessElement"); if !ok { return false }; rt := reflect.TypeOf((*sdf.RTracker)(nil)).Elem(); for i := 0; i < m.Type.NumIn(); i++ { if m.Type.In(i) == rt { return true } }; return false }

Try / catch

if err := beam.ParDo(s, fn, in); err != nil {
	if strings.Contains(err.Error(), "missing sdf.RTracker") { log.Fatalf("add RTracker at stated index: %v", err) }
}

Prevention

When it happens

Trigger: Implementing CreateInitialRestriction/SplitRestriction/RestrictionSize (a full SDF set) but forgetting the sdf.RTracker first parameter in ProcessElement, or placing it after the main inputs; detected during AsDoFn in beam.ParDo.

Common situations: Migrating an existing DoFn to splittable by adding the SDF methods but not updating ProcessElement; removing RTracker while refactoring ProcessElement's signature; inserting other leading parameters (context, event time) and misplacing RTracker.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of apache/beam@12126d8942 (2026-09-13). Data as JSON: /api/errors/98f2191a3ee9c411. Report an issue: GitHub.