apache/beam · error · ValueError
max_value must be greater than min_value
Error message
max_value must be greater than min_value
What it means
ScaleMinMax validates its constructor arguments: the max_value used for scaling must be strictly greater than min_value, otherwise tft.scale_by_min_max would be mathematically invalid. __init__ raises a ValueError when max_value <= min_value.
Solutions
- Swap or correct the values so max_value > min_value.
- If bounds come from data, add a guard that skips or defaults scaling for constant columns where min == max.
- Validate the config values before instantiating the transform.
Example fix
# before tft.ScaleMinMax(columns=['x'], min_value=10, max_value=10) # after tft.ScaleMinMax(columns=['x'], min_value=0, max_value=10)
Defensive patterns
Strategy: validation
Validate before calling
def make_scale_min_max(columns, min_value, max_value):
if not max_value > min_value:
raise ValueError('max_value must be greater than min_value')
return tft.ScaleMinMax(columns=columns, min_value=min_value, max_value=max_value) Type guard
def valid_min_max(min_value, max_value) -> bool:
return max_value > min_value Try / catch
try:
op = tft.ScaleMinMax(columns=['x'], min_value=mn, max_value=mx)
except ValueError as e:
if 'max_value must be greater' in str(e):
mn, mx = min(mn, mx), max(mn, mx) # normalize order
op = tft.ScaleMinMax(columns=['x'], min_value=mn, max_value=mx)
else:
raise Prevention
- Validate min < max in config-loading code before instantiating transforms.
- Sort or normalize bounds when they are computed from data.
- Reject constant columns (min == max) or fall back to ScaleToZScore.
- Add unit tests for bound-order validation in transform configs.
When it happens
Trigger: Constructing tft.ScaleMinMax(columns=[...], min_value=a, max_value=b) with b <= a (equal values or inverted order), including default misuse where both are set to the same number.
Common situations: Loading min/max from a config where order was flipped, computing bounds from data and getting equal values for constant columns, or typos swapping the arguments.
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
- An unsupported sink was specified
- artifact_location is not specified. Please specify the…
- At least one of --render_port or --render_output must be…
- buffer_sec must be >= 0, got
- Cannot skip negative number of header lines
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/c96402b6b5667fb3.
Report an issue: GitHub.
Appendix: source
Thrown at sdks/python/apache_beam/ml/transforms/tft.py:552
name: Optional[str] = None):
"""
This function applies a scaling transformation on the given columns
of incoming data. The transformation scales the input values to the
range [min_value, max_value].
Args:
columns: A list of column names to apply the transformation on.
min_value: The minimum value of the output range.
max_value: The maximum value of the output range.
name: A name for the operation (optional).
"""
super().__init__(columns)
self.min_value = min_value
self.max_value = max_value
self.name = name
if self.max_value <= self.min_value:
raise ValueError('max_value must be greater than min_value')
def apply_transform(
self, data: common_types.TensorType,
output_column_name: str) -> common_types.TensorType:
output = tft.scale_by_min_max(
x=data, output_min=self.min_value, output_max=self.max_value)
return {output_column_name: output}
@register_input_dtype(str)
class NGrams(TFTOperation):
def __init__(
self,
columns: list[str],
split_string_by_delimiter: Optional[str] = None,
*,
ngram_range: tuple[int, int] = (1, 1),View on GitHub (pinned to 12126d8942)