The query looks like this:
SELECT min(srid), max(srid), auth_name
FROM(SELECT srid, auth_name, srid - rank() OVER(ORDER BY srid) AS range FROM spatial_ref_sys) AS s
GROUP BY range, auth_name
ORDER BY 1;
This has overlaps when there are consecutive srids from different auth_srid e.g.:
Notice the the ESRI and EPSG entries are consecutive

The query in the code results in overlaps:

Changing the code to this seems to fix the problem:
SELECT min(srid), max(srid), auth_name
FROM(SELECT srid, auth_name, srid - rank() OVER(ORDER BY srid) AS range FROM spatial_ref_sys) AS s
GROUP BY range, auth_name
ORDER BY 1;
