apache/beam · error

invalid side pcollection: index %v

Error message

invalid side pcollection: index %v

What it means

validate() checks every side input passed via beam.SideInput options to TryParDo / TryCombinePerKey. This error reports that the PCollection attached as side input at the given index is invalid (the zero PCollection), so the transform cannot wire the side-input edge in the pipeline graph. The %v placeholder carries the zero-based index of the offending side input.

Source

Thrown at sdks/go/pkg/beam/validate.go:57

	t := col.Type()
	if typex.IsComposite(t.Type()) {
		panic(fmt.Sprintf("pcollection must be of non-composite type: %v", col))
	}
	return t
}

// validate validates and processes the input collection and options. Private convenience
// function.
func validate(s Scope, col PCollection, opts []Option) ([]SideInput, map[string]reflect.Type, error) {
	if !s.IsValid() {
		return nil, nil, errors.New("invalid scope")
	}
	if !col.IsValid() {
		return nil, nil, errors.New("invalid main pcollection")
	}
	side, defs := parseOpts(opts)
	for i, in := range side {
		if !in.Input.IsValid() {
			return nil, nil, errors.Errorf("invalid side pcollection: index %v", i)
		}
	}
	typedefs, err := makeTypedefs(defs)
	if err != nil {
		return nil, nil, err
	}
	return side, typedefs, nil
}

func makeTypedefs(list []TypeDefinition) (map[string]reflect.Type, error) {
	typedefs := make(map[string]reflect.Type)
	for _, v := range list {
		if !typex.IsUniversal(v.Var) {
			return nil, errors.Errorf("type var %s must be a universal type", v.Var)
		}
		if ok, err := typex.CheckConcrete(v.T); !ok {
			return nil, errors.Wrapf(err, "type value %s must be a concrete type", v.T)

View on GitHub (pinned to 12126d8942)

Solutions

  1. Look at the index in the message, find the corresponding SideInput entry, and trace where its PCollection came from; fix the failed/ignored construction that yielded the zero value.
  2. Handle the error from each Try* call producing side inputs instead of discarding it.
  3. Validate each side input before use with `if !pc.IsValid() { return fmt.Errorf("side input %q is invalid", name) }`.
  4. Check loop indices and slices for off-by-one or nil-entry mistakes when assembling []beam.SideInput.

Example fix

// before
side, _ := beam.TryParDo(s, produce, root)
beam.ParDo0(s, consume, main, beam.SideInput{Input: side}) // invalid side pcollection: index 0

// after
side, err := beam.TryParDo(s, produce, root)
if err != nil {
    return err
}
beam.ParDo0(s, consume, main, beam.SideInput{Input: side})
Defensive patterns

Strategy: validation

Validate before calling

for i, in := range sideInputs {
    if !in.Input.IsValid() {
        return fmt.Errorf("side input %d is not initialized", i)
    }
}

Prevention

When it happens

Trigger: beam.TryParDo(s, dofn, main, beam.SideInput{Input: badCol}) where badCol is a zero PCollection — from an ignored earlier Try-transform error or an unassigned variable; the formatted message reads e.g. 'invalid side pcollection: index 0'.

Common situations: Building side inputs in a loop where one source fails silently; mixing up slice indices so an empty slot is passed; ignoring the error return of a Try* call that produced the side-input collection; passing a PCollection from a different, failed sub-pipeline.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


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