Gdal vs rasterio in getting orthophoto transform coordinates

Wy are this 2 functions different?

from osgeo import gdal
import rasterio

class OrthophotoData:

    def get_transform_gdal(orthophoto_path):
        # Using gdal
        dataset = gdal.Open(orthophoto_path, gdal.GA_ReadOnly)
        aux = dataset.GetGeoTransform()
        dataset = None
        return aux

    def get_transform_rasterio(orthophoto_path):
        # Using rasterio
        with as src:
            transform = src.transform

        # rasterio's list order is different from gdal's
        aux= (transform[2], transform[0], transform[1],
              transform[5], transform[4], transform[3])
        return aux

If I use the first one, my code works fine.
If I use the second one, an error occurs in some place of the code, apparently not related to the function.

The error is
[…] line 612, in my_func
image1, transform = mask(src, geoms, crop=True)
File “…\env\Lib\site-packages\rasterio\”, line 178, in mask
shape_mask, transform, window = raster_geometry_mask(
File “…\env\Lib\site-packages\rasterio\”, line 80, in raster_geometry_mask
window = geometry_window(dataset, shapes, pad_x=pad_x, pad_y=pad_y)
File “…\env\Lib\site-packages\rasterio\”, line 451, in geometry_window
all_bounds = [bounds(shape, transform=~dataset.transform) for shape in
File “…\env\Lib\site-packages\”, line 565, in invert
raise TransformNotInvertibleError(“Cannot invert degenerate transform”)affine.TransformNotInvertibleError: Cannot invert degenerate transform

Please show a complete error message (starting from the line that says Traceback (most recent call last):, and format it the same way as the code (Python exception messages are designed to be read with that font; it will make the ^ symbols underline parts of the code in the stack trace, for example).

Sorry for wasting your time. I’ve found my mistake.
I’ve switched transform[3] with transform[4] position while constructing aux