apache/beam · error

resource.ParseMaxActiveBundlesPerWorker: unable to parse %q:

Error message

resource.ParseMaxActiveBundlesPerWorker: unable to parse %q: %v

What it means

ParseMaxActiveBundlesPerWorker converts a string to an integer bundle count hint using strconv.Atoi. On parse failure it panics with 'resource.ParseMaxActiveBundlesPerWorker: unable to parse %q: %v', since the hint value must be a plain integer.

Source

Thrown at sdks/go/pkg/beam/options/resource/hint.go:206

	// Max active bundles merge should be summed instead of taking the max.
	return MaxActiveBundlesPerWorker(outer.(maxActiveBundlesPerWorkerHint).value + h.value)
}

func (h maxActiveBundlesPerWorkerHint) String() string {
	return fmt.Sprintf("max_active_bundles_per_worker=%v", uint64(h.value))
}

// ParseMaxActiveBundlesPerWorker converts an int in string form into a hint.
// An invalid size format will cause ParseMaxActiveBundlesPerWorker to panic.
//
// Hints are advisory only and runners may not respect them.
//
// See https://beam.apache.org/documentation/runtime/resource-hints/ for more information about
// resource hints.
func ParseMaxActiveBundlesPerWorker(v string) Hint {
	b, err := strconv.Atoi(v)
	if err != nil {
		panic(fmt.Sprintf("resource.ParseMaxActiveBundlesPerWorker: unable to parse %q: %v", v, err))
	}
	return MaxActiveBundlesPerWorker(int64(b))
}

// Accelerator hints that this scope should be put in a machine with a given accelerator.
//
// Hints for accelerators will have formats that are runner specific.
// For example, the following is valid accelerator syntax for the Dataflow runner:
//
//	accelerator="type:<type>;count:<n>;<options>"
//
// Hints are advisory only and runners may not respect them.
//
// See https://beam.apache.org/documentation/runtime/resource-hints/ for more information about
// resource hints.
func Accelerator(v string) Hint {
	return acceleratorHint{value: v}
}

View on GitHub (pinned to 12126d8942)

Solutions

  1. Supply a plain base-10 integer string, e.g. '10'
  2. Trim whitespace and strip any suffix/units from the value
  3. Validate with strconv.Atoi in the caller before constructing the hint

Example fix

// before
resource.ParseMaxActiveBundlesPerWorker("3.5")
// after
resource.ParseMaxActiveBundlesPerWorker("3")
Defensive patterns

Strategy: validation

Validate before calling

if n, err := strconv.Atoi(v); err != nil || n <= 0 {
    return fmt.Errorf("invalid bundle count %q", v)
}

Try / catch

defer func() {
    if r := recover(); r != nil {
        err = fmt.Errorf("ParseMaxActiveBundlesPerWorker rejected value: %v", r)
    }
}()

Prevention

When it happens

Trigger: Calling resource.ParseMaxActiveBundlesPerWorker with a non-integer string like 'ten' or '3.5', or via --resource_hints with such a value for this hint.

Common situations: Passing a suffixed number ('10x'), a float, or an empty string from an unset/unquoted environment variable or flag.

Understand the failure class

Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.

Related errors


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