from typing import Union


def _chunk_size_value(value: str) -> Union[int, str]:
    """Validate/cast chunk size."""
    if value == "auto":
        return value
    else:
        try:
            size = int(value)
            if size > 0 or size == -1:
                return size
        except ValueError:
            pass

    raise ValueError(f"Invalid chunk size: {value}")