apache/beam · error

create has no values

Error message

create has no values

What it means

TryCreate requires a non-empty set of values to insert into the pipeline as a PCollection. Called with zero values, it fails with 'create has no values', wrapped with the scope context by addCreateCtx.

Source

Thrown at sdks/go/pkg/beam/create.go:51

//
// The returned PCollections can be used as any other PCollections. The values
// are JSON-coded. Each runner may place limits on the sizes of the values and
// Create should generally only be used for small collections.
func Create(s Scope, values ...any) PCollection {
	return Must(TryCreate(s, values...))
}

// CreateList inserts a fixed set of values into the pipeline from a slice or
// array. Unlike Create this supports the creation of an empty PCollection.
func CreateList(s Scope, list any) PCollection {
	return Must(TryCreateList(s, list))
}

// TryCreate inserts a fixed non-empty set of values into the pipeline. The
// values must be of the same type.
func TryCreate(s Scope, values ...any) (PCollection, error) {
	if len(values) == 0 {
		err := errors.New("create has no values")
		return PCollection{}, addCreateCtx(err, s)
	}

	t := reflect.ValueOf(values[0]).Type()
	return createList(s, values, t)
}

// TryCreateList inserts a fixed set of values into the pipeline from a slice or
// array. The values must be of the same type. Unlike TryCreate this supports
// the creation of an empty PCollection.
func TryCreateList(s Scope, list any) (PCollection, error) {
	val := reflect.ValueOf(list)
	if val.Kind() != reflect.Slice && val.Kind() != reflect.Array {
		err := errors.Errorf("input %v must be a slice or array", list)
		return PCollection{}, addCreateCtx(err, s)
	}

	var ret []any

View on GitHub (pinned to 12126d8942)

Solutions

  1. Guard that the value slice is non-empty before calling beam.Create
  2. Supply a default/fallback value set when input is empty
  3. If an empty collection is valid, build it via a different mechanism (e.g. Create with a sentinel then Filter, or a side input) since Create cannot be empty
  4. Handle the returned error and skip the transform when there is nothing to create

Example fix

// before
pc := beam.Create(s, items...) // panics/error if len(items)==0
// after
if len(items) == 0 {
    items = []string{""} // or handle empty case explicitly
}
pc := beam.Create(s, items...)
Defensive patterns

Strategy: validation

Validate before calling

if len(values) == 0 {
    return errors.New("beam.Create requires at least one value")
}
pc := beam.Create(s, values...)

Try / catch

pc, err := beam.TryCreate(s, values...)
if err != nil {
    if strings.Contains(err.Error(), "create has no values") { return handleEmptyInput() }
    return err
}

Prevention

When it happens

Trigger: Calling beam.Create (which delegates to TryCreate) with no variadic arguments, or a slice expanded with `values...` where the slice is empty.

Common situations: Expanding an empty slice into Create: `beam.Create(s, items...)` when items is empty; data-driven code paths where a default set of values was expected but config produced none.

Understand the failure class

Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.

Related errors


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