def _validate_max_result_size(
        self, max_result_size: Optional[int]
    ) -> Optional[int]:
        """
        Validate value of the ?max_result_size query parameter (if provided).
        """
        # Maximum limit for MongoDB collection document is 16 MB and the field itself can't be
        # larger than that obviously. And in reality due to the other fields, overhead, etc,
        # 14 is the upper limit.
        if not max_result_size:
            return max_result_size

        if max_result_size <= 0:
            raise ValueError("max_result_size must be a positive number")

        if max_result_size > 14 * 1024 * 1024:
            raise ValueError(
                "max_result_size query parameter must be smaller than 14 MB"
            )

        return max_result_size

        Validate value of the ?max_result_size query parameter (if provided).
        
st2api/st2api/controllers/v1/actionexecutions.py