nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: kinvolk/lokomotive
Pull request #937 (2020-09-10 09:52:36)

Fix controlplane components order
Also, added test to check the order


Patch:
diff --git a/pkg/platform/platform.go b/pkg/platform/platform.go
index 6c58369b..89254e5f 100644
--- a/pkg/platform/platform.go
+++ b/pkg/platform/platform.go
@@ -31,7 +31,7 @@ import (
 func CommonControlPlaneCharts() []helm.LokomotiveChart {
 	return []helm.LokomotiveChart{
 		{
-			Name:      "calico",
+			Name:      "pod-checkpointer",
 			Namespace: "kube-system",
 		},
 		{
@@ -43,7 +43,7 @@ func CommonControlPlaneCharts() []helm.LokomotiveChart {
 			Namespace: "kube-system",
 		},
 		{
-			Name:      "pod-checkpointer",
+			Name:      "calico",
 			Namespace: "kube-system",
 		},
 		{


Test patch:
diff --git a/pkg/platform/platform_test.go b/pkg/platform/platform_test.go
index e4359c0a..58289b0f 100644
--- a/pkg/platform/platform_test.go
+++ b/pkg/platform/platform_test.go
@@ -15,6 +15,7 @@
 package platform_test
 
 import (
+	"reflect"
 	"testing"
 
 	"github.com/kinvolk/lokomotive/pkg/platform"
@@ -45,3 +46,19 @@ func TestAppendVersionTag(t *testing.T) {
 		t.Fatalf("should append version tag to existing map")
 	}
 }
+
+func TestCommonControlPlaneChartsOrder(t *testing.T) {
+	expectedOrder := []string{"pod-checkpointer", "kube-apiserver", "kubernetes", "calico", "lokomotive", "bootstrap-secrets"} //nolint:lll
+
+	commonControlPlaneCharts := platform.CommonControlPlaneCharts()
+
+	actualOrder := []string{}
+
+	for _, v := range commonControlPlaneCharts {
+		actualOrder = append(actualOrder, v.Name)
+	}
+
+	if !reflect.DeepEqual(actualOrder, expectedOrder) {
+		t.Fatalf("expected order: %s, got: %s", expectedOrder, actualOrder)
+	}
+}
Repository: jax-ml/jax
Pull request #24040 (2024-10-01 02:09:00)

Delete jax.lib.xla_client.execute_with_python_values.
Delete jax.lib.xla_client.execute_with_python_values.

Nothing under jax.lib.xla_client is public, so there's no deprecation period required.



Patch:
diff --git a/jax/lib/xla_client.py b/jax/lib/xla_client.py
index a51625eb0..dbf07b8af 100644
--- a/jax/lib/xla_client.py
+++ b/jax/lib/xla_client.py
@@ -15,7 +15,6 @@
 from jax._src.lib import xla_client as _xc
 
 dtype_to_etype = _xc.dtype_to_etype
-execute_with_python_values = _xc.execute_with_python_values
 get_topology_for_devices = _xc.get_topology_for_devices
 heap_profile = _xc.heap_profile
 mlir_api_version = _xc.mlir_api_version


Test patch:
diff --git a/tests/compilation_cache_test.py b/tests/compilation_cache_test.py
index 75c52822a..e5222814f 100644
--- a/tests/compilation_cache_test.py
+++ b/tests/compilation_cache_test.py
@@ -40,7 +40,6 @@ from jax._src import path as pathlib
 from jax._src import test_util as jtu
 from jax._src import xla_bridge
 from jax._src.compilation_cache_interface import CacheInterface
-from jax._src.lib import xla_client
 from jax.experimental.pjit import pjit
 from jax.sharding import PartitionSpec as P
 import numpy as np
@@ -177,15 +176,11 @@ class CompilationCacheTest(CompilationCacheTestCase):
     executable_retrieved, compile_time_retrieved = cc.get_executable_and_time(
         key, compile_options, backend)
     inputs_to_executable = (
-        np.array(1, dtype=np.int32),
-        np.array(2, dtype=np.int32),
-    )
-    expected = xla_client.execute_with_python_values(
-        executable, inputs_to_executable, backend
-    )
-    actual = xla_client.execute_with_python_values(
-        executable_retrieved, inputs_to_executable, backend
+        jnp.array(1, dtype=np.int32),
+        jnp.array(2, dtype=np.int32),
     )
+    expected = executable.execute(inputs_to_executable)
+    actual = executable_retrieved.execute(inputs_to_executable)
     self.assertEqual(expected, actual)
     self.assertEqual(FAKE_COMPILE_TIME, compile_time_retrieved)
 
diff --git a/tests/lax_metal_test.py b/tests/lax_metal_test.py
index d3dada0d7..e403daba5 100644
--- a/tests/lax_metal_test.py
+++ b/tests/lax_metal_test.py
@@ -5590,7 +5590,6 @@ class LaxBackedNumpyTests(jtu.JaxTestCase):
       self.assertEqual(jax_result, numpy_result)
 
 
-from jaxlib import xla_client
 @unittest.skipIf(metal_plugin == None, "Tests require jax-metal plugin.")
 class ReportedIssuesTests(jtu.JaxTestCase):
   def dispatchOn(self, args, func, device=jax.devices('cpu')[0]):
@@ -5602,10 +5601,10 @@ class ReportedIssuesTests(jtu.JaxTestCase):
   @staticmethod
   def compile_and_exec(module, args, run_on_cpu=False):
     backend = jax.lib.xla_bridge.get_backend('METAL')
-    if (run_on_cpu):
+    if run_on_cpu:
       backend = jax.lib.xla_bridge.get_backend('cpu')
-    executables = backend.compile(module)
-    return xla_client.execute_with_python_values(executables, args, backend)
+    executable = backend.compile(module)
+    return executable.execute(args)
 
   @staticmethod
   def jax_metal_supported(target_ver):
Repository: jax-ml/jax
Pull request #24493 (2024-10-24 00:50:57)

Fix float0 behavior inside shard_map transpose under scan.
Fix float0 behavior inside shard_map transpose under scan.



Patch:
diff --git a/jax/experimental/shard_map.py b/jax/experimental/shard_map.py
index 24bed5034..03f3c9600 100644
--- a/jax/experimental/shard_map.py
+++ b/jax/experimental/shard_map.py
@@ -1652,7 +1652,7 @@ def _shard_map_transpose(out_cts, *args, jaxpr, mesh, in_names, out_names,
                          check_rep, rewrite, auto):
   mb_div = lambda x, y: x / y if y != 1 else x
   out_cts = [ad.Zero(_shard_aval(mesh, ns, x.aval)) if type(x) is ad.Zero
-      else x if rewrite
+      else x if rewrite or dtypes.dtype(x) == dtypes.float0
       else mb_div(x, prod(map(mesh.shape.get, _unmentioned2(mesh, ns))))
       for ns, x in zip(out_names, out_cts)]
   args = [x if type(x) is not ad.UndefinedPrimal else


Test patch:
diff --git a/tests/shard_map_test.py b/tests/shard_map_test.py
index f1da6b927..c5df1ca7c 100644
--- a/tests/shard_map_test.py
+++ b/tests/shard_map_test.py
@@ -1495,6 +1495,55 @@ class ShardMapTest(jtu.JaxTestCase):
     self.assertEqual(str(e1.primitive), 'psum2')
     self.assertEqual(str(e2.primitive), 'pbroadcast')
 
+  def test_transpose_float0(self):
+    mesh = jtu.create_mesh((4,), ('x',))
+
+    s = jax.sharding.NamedSharding(mesh, P(None, 'x'))
+
+    # vjp that triggers float0
+    @jax.custom_vjp
+    def f(x, _):
+      return x
+    def f_fwd(x, y):
+      return x, jnp.zeros(shape=y.shape, dtype=np.int32)
+    def f_rev(tmp, g):
+      return (g, tmp)
+    f.defvjp(f_fwd, f_rev)
+
+    # trivial vjp that consumes float0
+    @jax.custom_vjp
+    def g(x, y):
+      return x, y
+    def g_fwd(x, y):
+      return jax.vjp(lambda x, y: (x, y), x, y)
+    def g_bwd(vjp_fn, result):
+      return vjp_fn(result)
+    g.defvjp(g_fwd, g_bwd)
+
+    @partial(shard_map, mesh=mesh, in_specs=(P('x'), P()), out_specs=P())
+    def f_shmapped(x, y):
+      return jax.lax.psum(f(x, y).sum(), axis_name=('x'))
+
+    @partial(shard_map, mesh=mesh, check_rep=False,
+                       in_specs=P('x'), out_specs=(P('x'), P()))
+    def f_shmapped2(x, y):
+      return g(x, y)
+
+    def f_wrapper(x, y):
+      x, y = jax.lax.map(lambda xs: f_shmapped2(xs[0], xs[1]), (x, y))
+      return jax.lax.map(lambda xs: f_shmapped(xs[0], xs[1]), (x, y)).sum()
+
+    @partial(jax.jit, in_shardings=s,
+             out_shardings=jax.sharding.NamedSharding(mesh, P()))
+    def example(x, y):
+      return jax.grad(f_wrapper, allow_int=True, argnums=(0, 1))(x, y)
+
+    x = np.zeros(shape=(8,16), dtype=np.float32)
+    y = np.zeros(shape=(8,16), dtype=np.int32)
+    # Doesn't crash.
+    dx, dy = example(x, y)
+    self.assertEqual(dy.dtype, jax.dtypes.float0)
+
   def test_rewrite_binops(self):
     mesh = jtu.create_mesh((4,), ('x',))
Repository: jax-ml/jax
Pull request #24771 (2024-11-08 00:07:35)

Adding support for copy_p primitive to jet.
Adding support for copy_p primitive to jet.



Patch:
diff --git a/jax/experimental/jet.py b/jax/experimental/jet.py
index 8dd2a319a..827e4d01b 100644
--- a/jax/experimental/jet.py
+++ b/jax/experimental/jet.py
@@ -329,6 +329,7 @@ deflinear(lax.slice_p)
 deflinear(lax.reduce_sum_p)
 deflinear(lax.reduce_window_sum_p)
 deflinear(lax.fft_p)
+deflinear(lax.copy_p)
 deflinear(dispatch.device_put_p)
 
 def _dynamic_slice_jet_rule(primals_in, series_in, **params):


Test patch:
diff --git a/tests/jet_test.py b/tests/jet_test.py
index 4e437c044..7c2c71e9b 100644
--- a/tests/jet_test.py
+++ b/tests/jet_test.py
@@ -319,6 +319,8 @@ class JetTest(jtu.JaxTestCase):
   def test_dynamic_slice(self): self.unary_check(partial(lax.dynamic_slice, start_indices=(1,2), slice_sizes=(1,1)))
   @jtu.skip_on_devices("tpu")
   def test_dynamic_update_slice(self): self.unary_check(partial(lax.dynamic_update_slice, start_indices=(1,2), update=np.arange(6.0).reshape(2, 3)))
+  @jtu.skip_on_devices("tpu")
+  def test_copy(self):       self.unary_check(jnp.array)
 
 
   @jtu.skip_on_devices("tpu")
Repository: jax-ml/jax
Pull request #24772 (2024-11-08 00:54:53)

Allow 64-bit output types from ffi_call regardless of enable_x64 flag


Patch:
diff --git a/jax/_src/extend/ffi.py b/jax/_src/extend/ffi.py
index 60db34125..5207e6289 100644
--- a/jax/_src/extend/ffi.py
+++ b/jax/_src/extend/ffi.py
@@ -27,7 +27,7 @@ from jax._src import deprecations
 from jax._src import dispatch
 from jax._src import effects
 from jax._src import util
-from jax._src.callback import _check_shape_dtype, callback_batching_rule
+from jax._src.callback import callback_batching_rule
 from jax._src.interpreters import ad
 from jax._src.interpreters import batching
 from jax._src.interpreters import mlir
@@ -209,11 +209,14 @@ ResultMetadata = DuckTypedArray | core.AbstractToken
 
 def _result_avals(results: Sequence[ResultMetadata]) -> tuple[core.AbstractValue, ...]:
   avals: list[core.AbstractValue] = []
-  for result in results:
+  for idx, result in enumerate(results):
     if isinstance(result, core.AbstractToken):
       avals.append(result)
     else:
-      _check_shape_dtype(result)
+      if not hasattr(result, "shape") or not hasattr(result, "dtype"):
+        raise ValueError(
+            "All elements of result_shape_dtypes must have 'shape' and 'dtype' "
+            f"attributes. Got {result} at position {idx}.")
       avals.append(core.ShapedArray(result.shape, result.dtype))
   return tuple(avals)
 


Test patch:
diff --git a/tests/extend_test.py b/tests/extend_test.py
index 84a907c73..b4af8bc23 100644
--- a/tests/extend_test.py
+++ b/tests/extend_test.py
@@ -27,6 +27,7 @@ import jax.numpy as jnp
 
 from jax._src import abstract_arrays
 from jax._src import api
+from jax._src import config
 from jax._src import core
 from jax._src import linear_util
 from jax._src import prng
@@ -326,6 +327,21 @@ class FfiTest(jtu.JaxTestCase):
                                 "The use of ffi_call attributes requires"):
       jax.jit(fun).lower(jnp.ones(5)).as_text()
 
+  def testAllow64(self):
+    if config.enable_x64.value:
+      self.skipTest("Requires enable_x64=False")
+    def fun():
+      return jex.ffi.ffi_call("test", jax.ShapeDtypeStruct((), np.int64))()
+    self.assertIn("tensor<i64>", jax.jit(fun).lower().as_text())
+
+  def testInvalidResultType(self):
+    with self.assertRaisesRegex(
+        ValueError, "All elements of result_shape_dtypes.*position 0"):
+      jex.ffi.ffi_call("test", None)()
+    with self.assertRaisesRegex(
+        ValueError, "All elements of result_shape_dtypes.*position 1"):
+      jex.ffi.ffi_call("test", (jax.ShapeDtypeStruct((), np.float32), ()))()
+
 
 def ffi_call_geqrf(x, **kwargs):
   if jtu.test_device_matches(["cpu"]):
Repository: jax-ml/jax
Pull request #25151 (2024-11-27 20:22:15)

Raise a better error message if anything other than a sequence of ints is passed to make_mesh or create_device_mesh
Raise a better error message if anything other than a sequence of ints is passed to make_mesh or create_device_mesh



Patch:
diff --git a/jax/_src/mesh_utils.py b/jax/_src/mesh_utils.py
index 16e34e1af..d227b1eee 100644
--- a/jax/_src/mesh_utils.py
+++ b/jax/_src/mesh_utils.py
@@ -705,6 +705,12 @@ def _transpose_trick(
       *_TRANSPOSE_TRICKS[topology][mesh_shape_no_trivial_dims]
   )
 
+def _validate_axis_shapes(axis_shapes: Sequence[int], arg_name: str,
+                          fun_name: str):
+  if not all(isinstance(s, int) for s in axis_shapes):
+    raise ValueError(
+        f'{arg_name} passed to {fun_name} should be a sequence of ints. Got'
+        f' {axis_shapes}')
 
 def create_device_mesh(
     mesh_shape: Sequence[int],
@@ -740,7 +746,8 @@ def create_device_mesh(
   """
   if devices is None:
     devices = xb.devices()
-  if np.prod(mesh_shape) != len(devices):
+  _validate_axis_shapes(mesh_shape, 'mesh_shape', 'create_device_mesh')
+  if math.prod(mesh_shape) != len(devices):
     raise ValueError(
         f'Number of devices {len(devices)} must equal the product '
         f'of mesh_shape {mesh_shape}'
diff --git a/jax/_src/sharding_impls.py b/jax/_src/sharding_impls.py
index 8abe58e52..39d8aedfe 100644
--- a/jax/_src/sharding_impls.py
+++ b/jax/_src/sharding_impls.py
@@ -1714,6 +1714,7 @@ def make_mesh(axis_shapes: Sequence[int], axis_names: Sequence[str],
   """
   if devices is None:
     devices = xla_bridge.devices()
+  mesh_utils._validate_axis_shapes(axis_shapes, 'axis_shapes', 'make_mesh')
   axis_size = math.prod(axis_shapes)
   if axis_size > len(devices):
     raise ValueError(


Test patch:
diff --git a/tests/mesh_utils_test.py b/tests/mesh_utils_test.py
index 66f1fc9f6..d4db8fd3d 100644
--- a/tests/mesh_utils_test.py
+++ b/tests/mesh_utils_test.py
@@ -353,6 +353,12 @@ class MeshUtilsTest(test_util.JaxTestCase):
         )
     self.assertArraysEqual(assignment, expected_assignment_matrix)
 
+  def test_create_device_mesh_non_int_error(self):
+    with self.assertRaisesRegex(
+        ValueError,
+        "mesh_shape passed to create_device_mesh should be a sequence of ints"):
+      mesh_utils.create_device_mesh(((4,), 4))
+
   @parameterized.named_parameters(
       ('2x2x1', mock_2x2x1_devices,),
       ('2x2x4', mock_2x2x4_devices, ),
diff --git a/tests/pjit_test.py b/tests/pjit_test.py
index e541c6346..6bd05536c 100644
--- a/tests/pjit_test.py
+++ b/tests/pjit_test.py
@@ -4458,6 +4458,12 @@ class ArrayPjitTest(jtu.JaxTestCase):
     self.assertEqual(out2.sharding, s)
     self.assertEqual(out2.dtype, np.float32)
 
+  def test_make_mesh_non_int_error(self):
+    with self.assertRaisesRegex(
+        ValueError,
+        "axis_shapes passed to make_mesh should be a sequence of ints"):
+      jax.make_mesh(((4,), 4), ('x', 'y'))
+
   def test_jnp_array_reshard_error(self):
     if jax.device_count() < 2:
       self.skipTest('Requires >=2 devices')
Repository: googleapis/api-linter
Pull request #748 (2021-02-04 20:10:55)

fix: Fix the URI name check for AIP-134.


Patch:
diff --git a/rules/aip0134/aip0134.go b/rules/aip0134/aip0134.go
index ae850f5..9514305 100644
--- a/rules/aip0134/aip0134.go
+++ b/rules/aip0134/aip0134.go
@@ -48,7 +48,6 @@ func AddRules(r lint.RuleRegistry) error {
 
 var updateMethodRegexp = regexp.MustCompile("^Update(?:[A-Z]|$)")
 var updateReqMessageRegexp = regexp.MustCompile("^Update[A-Za-z0-9]*Request$")
-var updateURINameRegexp = regexp.MustCompile(`{([A-Za-z0-9_]+).name=[a-zA-Z/*]+}$`)
 
 // Returns true if this is a AIP-134 Update method, false otherwise.
 func isUpdateMethod(m *desc.MethodDescriptor) bool {
diff --git a/rules/aip0134/http_uri_name.go b/rules/aip0134/http_uri_name.go
index e968d27..0e0bdd0 100644
--- a/rules/aip0134/http_uri_name.go
+++ b/rules/aip0134/http_uri_name.go
@@ -29,12 +29,13 @@ var httpNameField = &lint.MethodRule{
 	OnlyIf: isUpdateMethod,
 	LintMethod: func(m *desc.MethodDescriptor) []lint.Problem {
 		fieldName := strcase.SnakeCase(m.GetName()[6:])
+		want := fmt.Sprintf("%s.name", fieldName)
+
 		// Establish that the RPC has expected HTTP pattern.
 		for _, httpRule := range utils.GetHTTPRules(m) {
-			matches := updateURINameRegexp.FindStringSubmatch(httpRule.URI)
-			if matches == nil || matches[1] != fieldName {
+			if _, ok := httpRule.GetVariables()[want]; !ok {
 				return []lint.Problem{{
-					Message:    fmt.Sprintf("Update methods should include the `%s.name` field in the URI.", fieldName),
+					Message:    fmt.Sprintf("Update methods should include the `%s` field in the URI.", want),
 					Descriptor: m,
 				}}
 			}


Test patch:
diff --git a/rules/aip0134/http_uri_name_test.go b/rules/aip0134/http_uri_name_test.go
index 0318e6b..bbcd83c 100644
--- a/rules/aip0134/http_uri_name_test.go
+++ b/rules/aip0134/http_uri_name_test.go
@@ -27,8 +27,8 @@ func TestHttpNameField(t *testing.T) {
 		MethodName string
 		problems   testutils.Problems
 	}{
-		{"Valid", "/v1/{big_book.name=publishers/*/books/*}",
-			"UpdateBigBook", nil},
+		{"Valid", "/v1/{big_book.name=publishers/*/books/*}", "UpdateBigBook", nil},
+		{"ValidWithNumber", "/v1/{dv360.name=publishers/*/dv360s/*}", "UpdateDv360", nil},
 		{"InvalidNoUnderscore", "/v1/{bigbook.name=publishers/*/books/*}",
 			"UpdateBigBook", testutils.Problems{{Message: "`big_book.name` field"}}},
 		{"InvalidVarNameBook", "/v1/{big_book=publishers/*/books/*}",
Repository: googleapis/api-linter
Pull request #753 (2021-02-10 17:17:27)

fix: Do not require undelete method if delete is not present.


Patch:
diff --git a/rules/aip0164/declarative_friendly_required.go b/rules/aip0164/declarative_friendly_required.go
index b6c817a..73ba59e 100644
--- a/rules/aip0164/declarative_friendly_required.go
+++ b/rules/aip0164/declarative_friendly_required.go
@@ -20,7 +20,8 @@ var declarativeFriendlyRequired = &lint.MessageRule{
 	LintMessage: func(m *desc.MessageDescriptor) []lint.Problem {
 		resource := m.GetName()
 		want := fmt.Sprintf("Undelete%s", resource)
-		if utils.FindMethod(m.GetFile(), want) == nil {
+		delete := fmt.Sprintf("Delete%s", resource)
+		if utils.FindMethod(m.GetFile(), want) == nil && utils.FindMethod(m.GetFile(), delete) != nil {
 			return []lint.Problem{{
 				Message:    fmt.Sprintf("Declarative-friendly %s should have an Undelete method.", resource),
 				Descriptor: m,


Test patch:
diff --git a/rules/aip0164/declarative_friendly_required_test.go b/rules/aip0164/declarative_friendly_required_test.go
index 5b05f41..84c71e6 100644
--- a/rules/aip0164/declarative_friendly_required_test.go
+++ b/rules/aip0164/declarative_friendly_required_test.go
@@ -20,8 +20,10 @@ func TestDeclarativeFriendlyRequired(t *testing.T) {
 		t.Run(test.testName, func(t *testing.T) {
 			file := testutils.ParseProto3Tmpl(t, `
 				import "google/api/resource.proto";
+				import "google/protobuf/empty.proto";
 				service Library {
 					rpc {{.MethodName}}({{.MethodName}}Request) returns (Book);
+					rpc DeleteBook(DeleteBookRequest) returns (google.protobuf.Empty);
 				}
 				message Book {
 					option (google.api.resource) = {
@@ -29,6 +31,7 @@ func TestDeclarativeFriendlyRequired(t *testing.T) {
 					};
 				}
 				message {{.MethodName}}Request {}
+				message DeleteBookRequest {}
 			`, test)
 			message := file.GetMessageTypes()[0]
 			problems := declarativeFriendlyRequired.Lint(file)
@@ -37,4 +40,24 @@ func TestDeclarativeFriendlyRequired(t *testing.T) {
 			}
 		})
 	}
+
+	// Also test that undelete is not required if delete is not present.
+	t.Run("ValidNoDelete", func(t *testing.T) {
+		file := testutils.ParseProto3String(t, `
+			import "google/api/resource.proto";
+			service Library {
+				rpc GetBook(GetBookRequest) returns (Book);
+			}
+			message Book {
+				option (google.api.resource) = {
+					style: DECLARATIVE_FRIENDLY
+				};
+			}
+			message GetBookRequest {}
+		`)
+		problems := declarativeFriendlyRequired.Lint(file)
+		if len(problems) > 0 {
+			t.Errorf("Got %v, expected no problems.", problems)
+		}
+	})
 }
Repository: googleapis/api-linter
Pull request #845 (2021-05-14 20:32:50)

feat: Permit `skip` in List requests.
Corresponds to https://github.com/aip-dev/google.aip.dev/pull/754.


Patch:
diff --git a/docs/rules/0132/request-unknown-fields.md b/docs/rules/0132/request-unknown-fields.md
index b335370..2406619 100644
--- a/docs/rules/0132/request-unknown-fields.md
+++ b/docs/rules/0132/request-unknown-fields.md
@@ -21,6 +21,7 @@ comes across any fields other than:
 - `string parent` ([AIP-132][])
 - `int32 page_size` ([AIP-158][])
 - `string page_token` ([AIP-158][])
+- `int32 skip` ([AIP-158][])
 - `string filter` ([AIP-132][])
 - `string order_by` ([AIP-132][])
 - `bool show_deleted` ([AIP-132][])
diff --git a/rules/aip0132/request_unknown_fields.go b/rules/aip0132/request_unknown_fields.go
index 2e91cbd..fe75657 100644
--- a/rules/aip0132/request_unknown_fields.go
+++ b/rules/aip0132/request_unknown_fields.go
@@ -24,6 +24,7 @@ var allowedFields = stringset.New(
 	"parent",       // AIP-132
 	"page_size",    // AIP-158
 	"page_token",   // AIP-158
+	"skip",         // AIP-158
 	"filter",       // AIP-132
 	"order_by",     // AIP-132
 	"show_deleted", // AIP-135


Test patch:
diff --git a/rules/aip0132/request_unknown_fields_test.go b/rules/aip0132/request_unknown_fields_test.go
index 53ab003..66b50f8 100644
--- a/rules/aip0132/request_unknown_fields_test.go
+++ b/rules/aip0132/request_unknown_fields_test.go
@@ -40,6 +40,7 @@ func TestUnknownFields(t *testing.T) {
 	}{
 		{"PageSize", "ListBooksRequest", "page_size", builder.FieldTypeInt32(), testutils.Problems{}},
 		{"PageToken", "ListBooksRequest", "page_token", builder.FieldTypeString(), testutils.Problems{}},
+		{"Skip", "ListBooksRequest", "skip", builder.FieldTypeInt32(), testutils.Problems{}},
 		{"Filter", "ListBooksRequest", "filter", builder.FieldTypeString(), testutils.Problems{}},
 		{"OrderBy", "ListBooksRequest", "order_by", builder.FieldTypeString(), testutils.Problems{}},
 		{"ShowDeleted", "ListBooksRequest", "show_deleted", builder.FieldTypeBool(), testutils.Problems{}},
Repository: googleapis/api-linter
Pull request #865 (2021-07-29 20:28:21)

fix: Do not overcount variables when additional bindings are used.


Patch:
diff --git a/rules/internal/utils/common_lints.go b/rules/internal/utils/common_lints.go
index fac22b2..a8cf979 100644
--- a/rules/internal/utils/common_lints.go
+++ b/rules/internal/utils/common_lints.go
@@ -197,7 +197,7 @@ func LintHTTPURIVariableCount(m *desc.MethodDescriptor, n int) []lint.Problem {
 
 	varsCount := 0
 	for _, httpRule := range GetHTTPRules(m) {
-		varsCount += len(httpRule.GetVariables())
+		varsCount = max(varsCount, len(httpRule.GetVariables()))
 	}
 	if varsCount != n {
 		return []lint.Problem{{
@@ -214,3 +214,10 @@ func LintHTTPURIVariableCount(m *desc.MethodDescriptor, n int) []lint.Problem {
 func LintHTTPURIHasNameVariable(m *desc.MethodDescriptor) []lint.Problem {
 	return LintHTTPURIHasVariable(m, "name")
 }
+
+func max(x, y int) int {
+	if x > y {
+		return x
+	}
+	return y
+}


Test patch:
diff --git a/rules/aip0133/http_uri_parent_test.go b/rules/aip0133/http_uri_parent_test.go
index 315ee4a..f9d8726 100644
--- a/rules/aip0133/http_uri_parent_test.go
+++ b/rules/aip0133/http_uri_parent_test.go
@@ -61,4 +61,34 @@ func TestHTTPURIParent(t *testing.T) {
 			}
 		})
 	}
+
+	t.Run("AdditionalBinding", func(t *testing.T) {
+		f := testutils.ParseProto3String(t, `
+			import "google/api/annotations.proto";
+			import "google/api/resource.proto";
+			service Library {
+				rpc CreateBook(CreateBookRequest) returns (Book) {
+					option (google.api.http) = {
+						post: "/v1/{parent=publishers/*}/books"
+						body: "book"
+						additional_bindings: {
+							post: "/v1/{parent=publishers/*/locations/*}/books"
+							body: "book"
+						}
+					};
+				}
+			}
+			message CreateBookRequest {}
+			message Book {
+				option (google.api.resource) = {
+					pattern: "publishers/{publisher}/books/{book}"
+				};
+			}
+		`)
+		method := f.GetServices()[0].GetMethods()[0]
+		problems := testutils.Problems{}
+		if diff := problems.SetDescriptor(method).Diff(httpURIParent.Lint(f)); diff != "" {
+			t.Error(diff)
+		}
+	})
 }