nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: nats-io/nats-server
Pull request #5923 (2024-09-24 16:13:48)

Add `pending` to `jsz` response and `statsz`
Signed-off-by: Neil Twigg <neil@nats.io>


Patch:
diff --git a/server/events.go b/server/events.go
index 466881e2..2a054cbf 100644
--- a/server/events.go
+++ b/server/events.go
@@ -971,6 +971,9 @@ func (s *Server) sendStatsz(subj string) {
 					Peer:   getHash(leader),
 					Size:   mg.ClusterSize(),
 				}
+				if ipq := s.jsAPIRoutedReqs; ipq != nil {
+					jStat.Meta.Pending = ipq.len()
+				}
 			}
 		}
 		jStat.Limits = &s.getOpts().JetStreamLimits
diff --git a/server/monitor.go b/server/monitor.go
index 91dc7b28..6ee36614 100644
--- a/server/monitor.go
+++ b/server/monitor.go
@@ -1464,6 +1464,9 @@ func (s *Server) updateJszVarz(js *jetStream, v *JetStreamVarz, doConfig bool) {
 			if ci.Leader == s.info.Name {
 				v.Meta.Replicas = ci.Replicas
 			}
+			if ipq := s.jsAPIRoutedReqs; ipq != nil {
+				v.Meta.Pending = ipq.len()
+			}
 		}
 	}
 }
@@ -2794,6 +2797,7 @@ type MetaClusterInfo struct {
 	Peer     string      `json:"peer,omitempty"`
 	Replicas []*PeerInfo `json:"replicas,omitempty"`
 	Size     int         `json:"cluster_size"`
+	Pending  int         `json:"pending"`
 }
 
 // JSInfo has detailed information on JetStream.
@@ -2996,6 +3000,9 @@ func (s *Server) Jsz(opts *JSzOptions) (*JSInfo, error) {
 			if isLeader {
 				jsi.Meta.Replicas = ci.Replicas
 			}
+			if ipq := s.jsAPIRoutedReqs; ipq != nil {
+				jsi.Meta.Pending = ipq.len()
+			}
 		}
 	}
 


Test patch:
diff --git a/server/jetstream_cluster_4_test.go b/server/jetstream_cluster_4_test.go
index c62fe4e4..5de16507 100644
--- a/server/jetstream_cluster_4_test.go
+++ b/server/jetstream_cluster_4_test.go
@@ -3903,3 +3903,47 @@ func TestJetStreamClusterAPILimitAdvisory(t *testing.T) {
 	require_Equal(t, advisory.Domain, _EMPTY_)     // No JetStream domain was set.
 	require_Equal(t, advisory.Dropped, queueLimit) // Configured queue limit.
 }
+
+func TestJetStreamPendingRequestsInJsz(t *testing.T) {
+	c := createJetStreamClusterExplicit(t, "R3S", 3)
+	defer c.shutdown()
+
+	c.waitOnLeader()
+	metaleader := c.leader()
+
+	sjs := metaleader.getJetStream()
+	sjs.mu.Lock()
+	sub := &subscription{
+		subject: []byte("$JS.API.VERY_SLOW"),
+		icb: func(sub *subscription, client *client, acc *Account, subject, reply string, rmsg []byte) {
+			select {
+			case <-client.srv.quitCh:
+			case <-time.After(time.Second * 3):
+			}
+		},
+	}
+	err := metaleader.getJetStream().apiSubs.Insert(sub)
+	sjs.mu.Unlock()
+
+	require_NoError(t, err)
+
+	nc, _ := jsClientConnect(t, c.randomNonLeader())
+	defer nc.Close()
+
+	inbox := nc.NewRespInbox()
+	msg := &nats.Msg{
+		Subject: "$JS.API.VERY_SLOW",
+		Reply:   inbox,
+	}
+
+	// Fall short of hitting the API limit by a little bit,
+	// otherwise the requests get drained away.
+	for i := 0; i < JSDefaultRequestQueueLimit-10; i++ {
+		require_NoError(t, nc.PublishMsg(msg))
+	}
+
+	jsz, err := metaleader.Jsz(nil)
+	require_NoError(t, err)
+	require_True(t, jsz.Meta != nil)
+	require_NotEqual(t, jsz.Meta.Pending, 0)
+}
Repository: nats-io/nats-server
Pull request #5980 (2024-10-09 15:58:36)

[BUMP] jwt to v2.7.2
[BUMP] jwt to v2.7.2 - which retracts case-sensitive jwt.TagList
[FIX] jwt cluster test reference ClusterTraffic as a string

Signed-off-by: Alberto Ricart <alberto@synadia.com>



Patch:
diff --git a/go.mod b/go.mod
index 4c779a9c..b2efd840 100644
--- a/go.mod
+++ b/go.mod
@@ -8,7 +8,7 @@ require (
 	github.com/google/go-tpm v0.9.0
 	github.com/klauspost/compress v1.17.10
 	github.com/minio/highwayhash v1.0.3
-	github.com/nats-io/jwt/v2 v2.6.0
+	github.com/nats-io/jwt/v2 v2.7.2
 	github.com/nats-io/nats.go v1.36.0
 	github.com/nats-io/nkeys v0.4.7
 	github.com/nats-io/nuid v1.0.1
diff --git a/go.sum b/go.sum
index 68dc9675..92e49feb 100644
--- a/go.sum
+++ b/go.sum
@@ -6,8 +6,8 @@ github.com/klauspost/compress v1.17.10 h1:oXAz+Vh0PMUvJczoi+flxpnBEPxoER1IaAnU/N
 github.com/klauspost/compress v1.17.10/go.mod h1:pMDklpSncoRMuLFrf1W9Ss9KT+0rH90U12bZKk7uwG0=
 github.com/minio/highwayhash v1.0.3 h1:kbnuUMoHYyVl7szWjSxJnxw11k2U709jqFPPmIUyD6Q=
 github.com/minio/highwayhash v1.0.3/go.mod h1:GGYsuwP/fPD6Y9hMiXuapVvlIUEhFhMTh0rxU3ik1LQ=
-github.com/nats-io/jwt/v2 v2.6.0 h1:yXoBTdEotZw3NujMT+Nnu1UPNlFWdKQ3d0JJF/+pJag=
-github.com/nats-io/jwt/v2 v2.6.0/go.mod h1:ZdWS1nZa6WMZfFwwgpEaqBV8EPGVgOTDHN/wTbz0Y5A=
+github.com/nats-io/jwt/v2 v2.7.2 h1:SCRjfDLJ2q8naXp8YlGJJS5/yj3wGSODFYVi4nnwVMw=
+github.com/nats-io/jwt/v2 v2.7.2/go.mod h1:kB6QUmqHG6Wdrzj0KP2L+OX4xiTPBeV+NHVstFaATXU=
 github.com/nats-io/nats.go v1.36.0 h1:suEUPuWzTSse/XhESwqLxXGuj8vGRuPRoG7MoRN/qyU=
 github.com/nats-io/nats.go v1.36.0/go.mod h1:Ubdu4Nh9exXdSz0RVWRFBbRfrbSxOYd26oF0wkWclB8=
 github.com/nats-io/nkeys v0.4.7 h1:RwNJbbIdYCoClSDNY7QVKZlyb/wfT6ugvFCiKy6vDvI=


Test patch:
diff --git a/server/jetstream_jwt_test.go b/server/jetstream_jwt_test.go
index 9f5e937e..ee39d519 100644
--- a/server/jetstream_jwt_test.go
+++ b/server/jetstream_jwt_test.go
@@ -1577,11 +1577,11 @@ func TestJetStreamJWTClusterAccountNRG(t *testing.T) {
 
 	// We'll try flipping the state a few times and then do some sanity
 	// checks to check that it took effect.
-	thirdAcc := fmt.Sprintf("account:%s", aExpPub2)
+	thirdAcc := jwt.ClusterTraffic(fmt.Sprintf("account:%s", aExpPub2))
 	// TODO: Not currently testing thirdAcc because we haven't enabled this
 	// functionality yet. If/when we do enable, this test is ready just by
 	// uncommenting the third state below.
-	for _, state := range []string{"system", "owner" /*, thirdAcc */} {
+	for _, state := range []jwt.ClusterTraffic{"system", "owner" /*, thirdAcc */} {
 		accClaim.ClusterTraffic = state
 		accJwt = encodeClaim(t, accClaim, aExpPub)
Repository: pypa/twine
Pull request #1010 (2023-08-27 20:02:33)

upload: warn the user if their signature(s) are ignored
This is an initial step towards #1009: if `twine upload` sees that any to-be-uploaded dist has an associated PGP signature and that the index URL looks like `pypi.org` (i.e. PyPI or TestPyPI), it emits a warning notifying the user that their PGP signature will be silently ignored.

See #1009.

sigmavirus24: Thanks @woodruffw I think one warning (rather than one per artifact) is best for now. I think a second warning for non-PyPI URLs could be useful to indicate we're considering removing support altogether and not just for PyPI uploads (with a link to the issue you opened or some other venue).

Patch:
diff --git a/twine/commands/upload.py b/twine/commands/upload.py
index 34d3c8c..75bf21a 100644
--- a/twine/commands/upload.py
+++ b/twine/commands/upload.py
@@ -124,6 +124,18 @@ def upload(upload_settings: settings.Settings, dists: List[str]) -> None:
         _make_package(filename, signatures, upload_settings) for filename in uploads
     ]
 
+    # Warn the user if they're trying to upload a PGP signature to PyPI
+    # or TestPyPI, which will (as of May 2023) ignore it.
+    # This check is currently limited to just those indices, since other
+    # indices may still support PGP signatures.
+    if any(p.gpg_signature for p in packages_to_upload) and repository_url.startswith(
+        (utils.DEFAULT_REPOSITORY, utils.TEST_REPOSITORY)
+    ):
+        logger.warning(
+            "One or more packages has an associated PGP signature; "
+            "these will be silently ignored by the index"
+        )
+
     repository = upload_settings.create_repository()
     uploaded_packages = []
 


Test patch:
diff --git a/tests/test_upload.py b/tests/test_upload.py
index 438dbac..c428306 100644
--- a/tests/test_upload.py
+++ b/tests/test_upload.py
@@ -162,7 +162,7 @@ def test_print_response_if_verbose(upload_settings, stub_response, caplog):
     assert caplog.messages.count(response_log) == 2
 
 
-def test_success_with_pre_signed_distribution(upload_settings, stub_repository):
+def test_success_with_pre_signed_distribution(upload_settings, stub_repository, caplog):
     """Add GPG signature provided by user to uploaded package."""
     # Upload a pre-signed distribution
     result = upload.upload(
@@ -177,6 +177,12 @@ def test_success_with_pre_signed_distribution(upload_settings, stub_repository):
         b"signature",
     )
 
+    # Ensure that a warning is emitted.
+    assert (
+        "One or more packages has an associated PGP signature; these will "
+        "be silently ignored by the index" in caplog.messages
+    )
+
 
 def test_exception_with_only_pre_signed_file(upload_settings, stub_repository):
     """Raise an exception when only a signed file is uploaded."""
Repository: pypa/twine
Pull request #1099 (2024-05-01 23:06:59)

upload: prevent --attestations on non-PyPI indices
This is just a small follow-up on #1098, forbidding `--attestations` when the user requests an index URL other than PyPI or TestPyPI.

xref #1094


Patch:
diff --git a/twine/commands/upload.py b/twine/commands/upload.py
index c25d136..4e45be7 100644
--- a/twine/commands/upload.py
+++ b/twine/commands/upload.py
@@ -170,12 +170,24 @@ def upload(upload_settings: settings.Settings, dists: List[str]) -> None:
     :raises requests.HTTPError:
         The repository responded with an error.
     """
+    upload_settings.check_repository_url()
+    repository_url = cast(str, upload_settings.repository_config["repository"])
+
+    # Attestations are only supported on PyPI and TestPyPI at the moment.
+    # We fail early here if the user requests any other index, to prevent
+    # users from attempting to use `--attestations` on other indices and
+    # failing bugs when upload fails.
+    if upload_settings.attestations and not repository_url.startswith(
+        (utils.DEFAULT_REPOSITORY, utils.TEST_REPOSITORY)
+    ):
+        raise exceptions.InvalidConfiguration(
+            "The --attestations flag may only be used with PyPI and TestPyPI"
+        )
+
     dists = commands._find_dists(dists)
     # Determine if the user has passed in pre-signed distributions or any attestations.
     uploads, signatures, attestations_by_dist = _split_inputs(dists)
 
-    upload_settings.check_repository_url()
-    repository_url = cast(str, upload_settings.repository_config["repository"])
     print(f"Uploading distributions to {repository_url}")
 
     packages_to_upload = [


Test patch:
diff --git a/tests/test_upload.py b/tests/test_upload.py
index 21b91d0..589bfde 100644
--- a/tests/test_upload.py
+++ b/tests/test_upload.py
@@ -670,3 +670,16 @@ def test_check_status_code_for_wrong_repo_url(repo_url, upload_settings, stub_re
                 helpers.NEW_WHEEL_FIXTURE,
             ],
         )
+
+
+def test_upload_rejects_attestations_non_pypi(upload_settings):
+    upload_settings.repository_config["repository"] = "https://notpypi.example.com"
+    upload_settings.attestations = True
+
+    with pytest.raises(
+        exceptions.InvalidConfiguration, match="may only be used with PyPI and TestPyPI"
+    ):
+        upload.upload(
+            upload_settings,
+            [helpers.WHEEL_FIXTURE, helpers.WHEEL_FIXTURE + ".foo.attestation"],
+        )
Repository: pypa/twine
Pull request #1191 (2024-12-03 16:13:43)

Use "source" as python-version for sdist uploads
Although not setting the "pyversion" field in the upload data works, and despite it not being used for much, this is what PyPI (and most likely other indexes) expects.

This will simplify follow-up patches.


Patch:
diff --git a/changelog/1191.misc.txt b/changelog/1191.misc.txt
new file mode 100644
index 0000000..a9edc53
--- /dev/null
+++ b/changelog/1191.misc.txt
@@ -0,0 +1,3 @@
+- Use ``"source"`` instead of ``None`` as ``pyversion`` for ``sdist``
+  uploads. This is what PyPI (and most likely other package indexes)
+  expects.
diff --git a/twine/package.py b/twine/package.py
index 8bcec21..2c3a8f7 100644
--- a/twine/package.py
+++ b/twine/package.py
@@ -157,7 +157,6 @@ class PackageFile:
                 )
             raise exceptions.InvalidDistribution(msg)
 
-        py_version: Optional[str]
         if dtype == "bdist_egg":
             (dist,) = importlib_metadata.Distribution.discover(path=[filename])
             py_version = dist.metadata["Version"]
@@ -165,8 +164,11 @@ class PackageFile:
             py_version = cast(wheel.Wheel, meta).py_version
         elif dtype == "bdist_wininst":
             py_version = cast(wininst.WinInst, meta).py_version
+        elif dtype == "sdist":
+            py_version = "source"
         else:
-            py_version = None
+            # This should not be reached.
+            raise ValueError
 
         return cls(
             filename, comment, cast(CheckedDistribution, meta), py_version, dtype


Test patch:
diff --git a/tests/test_package.py b/tests/test_package.py
index be3d954..3712574 100644
--- a/tests/test_package.py
+++ b/tests/test_package.py
@@ -466,3 +466,9 @@ def test_malformed_from_file(monkeypatch):
 def test_package_from_egg():
     filename = "tests/fixtures/twine-3.3.0-py3.9.egg"
     package_file.PackageFile.from_filename(filename, comment=None)
+
+
+def test_package_from_sdist():
+    filename = "tests/fixtures/twine-1.5.0.tar.gz"
+    p = package_file.PackageFile.from_filename(filename, comment=None)
+    assert p.python_version == "source"