nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: TobikoData/sqlmesh
Pull request #4898 (2025-07-03 20:56:44)

fix: check sqlmesh version before sqlglot/schema
Prior to this PR, if a user was running a version that didn't match the remote SQLMesh version, they would likely see a schema or sqlglot version mismatched error before SQLMesh. Erroring on SQLMesh is more useful since it makes it more clear what the issue is - version/SQLGLot should just be backup checks. 


Patch:
diff --git a/sqlmesh/core/state_sync/base.py b/sqlmesh/core/state_sync/base.py
index 4a4e3185..6c2097d7 100644
--- a/sqlmesh/core/state_sync/base.py
+++ b/sqlmesh/core/state_sync/base.py
@@ -245,6 +245,15 @@ class StateReader(abc.ABC):
                     f"{lib} (local) is using version '{local}' which is behind '{remote}' (remote).{upgrade_suggestion}"
                 )
 
+            if major_minor(SQLMESH_VERSION) != major_minor(versions.sqlmesh_version):
+                raise_error(
+                    "SQLMesh",
+                    SQLMESH_VERSION,
+                    versions.sqlmesh_version,
+                    remote_package_version=versions.sqlmesh_version,
+                    ahead=major_minor(SQLMESH_VERSION) > major_minor(versions.sqlmesh_version),
+                )
+
             if SCHEMA_VERSION != versions.schema_version:
                 raise_error(
                     "SQLMesh",
@@ -263,15 +272,6 @@ class StateReader(abc.ABC):
                     ahead=major_minor(SQLGLOT_VERSION) > major_minor(versions.sqlglot_version),
                 )
 
-            if major_minor(SQLMESH_VERSION) != major_minor(versions.sqlmesh_version):
-                raise_error(
-                    "SQLMesh",
-                    SQLMESH_VERSION,
-                    versions.sqlmesh_version,
-                    remote_package_version=versions.sqlmesh_version,
-                    ahead=major_minor(SQLMESH_VERSION) > major_minor(versions.sqlmesh_version),
-                )
-
         return versions
 
     @abc.abstractmethod


Test patch:
diff --git a/tests/core/state_sync/test_state_sync.py b/tests/core/state_sync/test_state_sync.py
index cf1d35bb..f0b1bf00 100644
--- a/tests/core/state_sync/test_state_sync.py
+++ b/tests/core/state_sync/test_state_sync.py
@@ -2091,7 +2091,7 @@ def test_version_schema(state_sync: EngineAdapterStateSync, tmp_path) -> None:
 
     with pytest.raises(
         SQLMeshError,
-        match=rf"SQLMesh \(local\) is using version '{SCHEMA_VERSION}' which is ahead of '0'",
+        match=rf"SQLMesh \(local\) is using version '{SQLMESH_VERSION}' which is ahead of '0.0.0' \(remote\). Please run a migration \('sqlmesh migrate' command\).",
     ):
         state_sync.get_versions()
Repository: planetlabs/planet-client-python
Pull request #471 (2022-05-02 18:39:18)

Change version to 2.0dev
This will help prevent confusion in environments between pre-releases and the final release.


Patch:
diff --git a/planet/__version__.py b/planet/__version__.py
index afced14..0e77cbd 100644
--- a/planet/__version__.py
+++ b/planet/__version__.py
@@ -1,1 +1,1 @@
-__version__ = '2.0.0'
+__version__ = '2.0dev'
diff --git a/planet/exceptions.py b/planet/exceptions.py
index cd56a7b..49f2761 100644
--- a/planet/exceptions.py
+++ b/planet/exceptions.py
@@ -75,3 +75,8 @@ class ClientError(PlanetError):
 class AuthException(ClientError):
     '''Exceptions encountered during authentication'''
     pass
+
+
+class PagingError(PlanetError):
+    '''For errors that occur during paging.'''
+    pass
diff --git a/planet/models.py b/planet/models.py
index 71c82cc..0ef46cf 100644
--- a/planet/models.py
+++ b/planet/models.py
@@ -22,6 +22,8 @@ import string
 import httpx
 from tqdm.asyncio import tqdm
 
+from .exceptions import PagingError
+
 LOGGER = logging.getLogger(__name__)
 
 
@@ -338,8 +340,18 @@ class Paged():
             resp = await self._do_request(request)
             page = resp.json()
             yield page
+
+            # If the next URL is the same as the previous URL we will
+            # get the same response and be stuck in a page cycle. This
+            # has happened in development and could happen in the case
+            # of a bug in the production API.
+            prev_url = next_url
             next_url = self._next_link(page)
 
+            if next_url == prev_url:
+                raise PagingError(
+                    "Page cycle detected at {!r}".format(next_url))
+
     def _next_link(self, page):
         try:
             next_link = page[self.LINKS_KEY][self.NEXT_KEY]


Test patch:
diff --git a/tests/unit/test_models.py b/tests/unit/test_models.py
index 38b6f70..fb3a4b7 100644
--- a/tests/unit/test_models.py
+++ b/tests/unit/test_models.py
@@ -23,6 +23,7 @@ from httpx import URL
 import pytest
 
 from planet import models
+from planet.exceptions import PagingError
 
 LOGGER = logging.getLogger(__name__)
 
@@ -235,3 +236,21 @@ async def test_Paged_limit(get_pages):
     req = MagicMock()
     paged = models.Paged(req, get_pages, limit=3)
     assert [1, 2, 3] == [i async for i in paged]
+
+
+@pytest.mark.asyncio
+async def test_break_page_cycle():
+    """Check that we break out of a page cycle."""
+
+    async def func(req):
+        return mock_http_response(json={
+            'links': {
+                'next': 'blah'
+            }, 'items': [1, 2]
+        })
+
+    req = MagicMock()
+    paged = models.Paged(req, func, limit=None)
+
+    with pytest.raises(PagingError):
+        [item async for item in paged]