apache/beam · error

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

Error message

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

What it means

ParseMinRAM converts a human-readable byte-size string (e.g. '4GiB') via humanize.ParseBytes into a MinRAMBytes resource hint. If parsing fails, it panics with 'resource.ParseMinRAM: unable to parse %q: %v', because an unparseable memory hint is treated as a hard configuration error at pipeline construction.

Source

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

// 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 MinRAMBytes(v uint64) Hint {
	return minRAMHint{value: int64(v)}
}

// ParseMinRAM converts various byte units, including MB, GB, MiB, and GiB into a hint.
// An invalid byte size format will cause ParseMinRAM 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 ParseMinRAM(v string) Hint {
	b, err := humanize.ParseBytes(v)
	if err != nil {
		panic(fmt.Sprintf("resource.ParseMinRAM: unable to parse %q: %v", v, err))
	}
	return MinRAMBytes(b)
}

type minRAMHint struct {
	value int64
}

func (minRAMHint) URN() string {
	return "beam:resources:min_ram_bytes:v1"
}

func (h minRAMHint) Payload() []byte {
	// Go strings are utf8, and if the string is ascii,
	// byte conversion handles that directly.
	return []byte(strconv.FormatInt(h.value, 10))
}

View on GitHub (pinned to 12126d8942)

Solutions

  1. Pass a valid size string accepted by dustin/go-humanize, e.g. '8GiB', '4294967296', '8 GB'
  2. Trim whitespace and remove non-numeric characters from the value
  3. Pre-validate with humanize.ParseBytes in a helper before calling ParseMinRAM

Example fix

// before
resource.ParseMinRAM("8 gigs")
// after
resource.ParseMinRAM("8GiB")
Defensive patterns

Strategy: validation

Validate before calling

if _, err := humanize.ParseBytes(v); err != nil {
    return fmt.Errorf("invalid min_ram %q: %w", v, err)
}

Try / catch

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

Prevention

When it happens

Trigger: Calling resource.ParseMinRAM with a non-numeric or unknown-unit string such as '8GB?' or 'four gigs', or supplying such a value through jobopts --resource_hints=min_ram=<bad>.

Common situations: Typos in the size string, using unit spellings humanize.ParseBytes does not accept (e.g. '8 TB ' with a trailing space), or locale-formatted numbers with commas.

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/5b033f7d2c30bee8. Report an issue: GitHub.