nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: TobikoData/sqlmesh
Pull request #2583 (2024-05-08 18:51:09)

fix: monospace `plan_id`
This should properly format the plan id in this message:
<img width="582" alt="Screenshot 2024-05-08 at 14 50 45" src="https://github.com/TobikoData/sqlmesh/assets/484152/3e15d4a5-7af2-4c6e-b7cf-3d24a75c96da">



Patch:
diff --git a/sqlmesh/core/notification_target.py b/sqlmesh/core/notification_target.py
index 80236885..acf37c09 100644
--- a/sqlmesh/core/notification_target.py
+++ b/sqlmesh/core/notification_target.py
@@ -123,7 +123,7 @@ class BaseNotificationTarget(PydanticModel, frozen=True):
         """
         self.send(
             NotificationStatus.INFO,
-            f"Plan {plan_id} apply started for environment `{environment}`.",
+            f"Plan `{plan_id}` apply started for environment `{environment}`.",
         )
 
     @notify(NotificationEvent.APPLY_END)
@@ -136,7 +136,7 @@ class BaseNotificationTarget(PydanticModel, frozen=True):
         """
         self.send(
             NotificationStatus.SUCCESS,
-            f"Plan {plan_id} apply finished for environment `{environment}`.",
+            f"Plan `{plan_id}` apply finished for environment `{environment}`.",
         )
 
     @notify(NotificationEvent.RUN_START)
@@ -180,7 +180,7 @@ class BaseNotificationTarget(PydanticModel, frozen=True):
         """
         self.send(
             NotificationStatus.FAILURE,
-            f"Plan {plan_id} in environment `{environment}` apply failed.",
+            f"Plan `{plan_id}` in environment `{environment}` apply failed.",
             exc=exc,
         )
 


Test patch:
diff --git a/tests/core/test_notification_target.py b/tests/core/test_notification_target.py
index 9adff6fb..57b21f2e 100644
--- a/tests/core/test_notification_target.py
+++ b/tests/core/test_notification_target.py
@@ -38,7 +38,7 @@ def test_notify(notification_target_manager_with_spy):
     spy.assert_called_once_with(
         mock.ANY,
         NotificationStatus.INFO,
-        "Plan a-plan-id apply started for environment `prod`.",
+        "Plan `a-plan-id` apply started for environment `prod`.",
     )
 
     spy.reset_mock()
@@ -46,7 +46,7 @@ def test_notify(notification_target_manager_with_spy):
     spy.assert_called_once_with(
         mock.ANY,
         NotificationStatus.SUCCESS,
-        "Plan a-plan-id apply finished for environment `prod`.",
+        "Plan `a-plan-id` apply finished for environment `prod`.",
     )
 
     # No notification target configured for APPLY_FAILURE event
@@ -65,7 +65,7 @@ def test_notify_user(notification_target_manager_with_spy):
     spy.assert_called_once_with(
         mock.ANY,
         NotificationStatus.INFO,
-        "Plan a-plan-id apply started for environment `prod`.",
+        "Plan `a-plan-id` apply started for environment `prod`.",
     )
 
     # No notification target configured for APPLY_END event for test_user
Repository: kentik/ktranslate
Pull request #442 (2022-09-26 18:02:59)

Support ipv6 ips for hextoip conversion
#441 handle ipv6. 

Is this what you are thinking here? 


Patch:
diff --git a/pkg/api/api.go b/pkg/api/api.go
index 1918b54..d86fdbd 100644
--- a/pkg/api/api.go
+++ b/pkg/api/api.go
@@ -406,7 +406,7 @@ func (api *KentikApi) getSynthInfo(ctx context.Context) error {
 }
 
 func (api *KentikApi) EnsureDevice(ctx context.Context, conf *kt.SnmpDeviceConfig) error {
-	if api == nil || len(api.config.KentikCreds) == 0 {
+	if api == nil || api.config == nil || len(api.config.KentikCreds) == 0 {
 		return nil
 	}
 
diff --git a/pkg/inputs/snmp/util/util.go b/pkg/inputs/snmp/util/util.go
index f06301d..eacba53 100644
--- a/pkg/inputs/snmp/util/util.go
+++ b/pkg/inputs/snmp/util/util.go
@@ -310,6 +310,8 @@ and display it as a string 10.0.100.10
 */
 func hexToIP(bv []byte) (int64, string, map[string]string) {
 	switch len(bv) {
+	case 16:
+		return 0, net.IP(bv).String(), nil
 	case 8:
 		return 0, fmt.Sprintf("%d.%d.%d.%d",
 			binary.BigEndian.Uint16(bv[0:2]),


Test patch:
diff --git a/pkg/inputs/snmp/util/util_test.go b/pkg/inputs/snmp/util/util_test.go
index 050627d..8d46082 100644
--- a/pkg/inputs/snmp/util/util_test.go
+++ b/pkg/inputs/snmp/util/util_test.go
@@ -148,8 +148,9 @@ func TestHexToIP(t *testing.T) {
 	l := lt.NewTestContextL(logger.NilContext, t)
 
 	tests := map[string][]byte{
-		"10.0.100.10": []byte{0x00, 0x0a, 0x00, 0x00, 0x00, 0x64, 0x00, 0x0a},
-		"10.0.100.11": []byte{0x0a, 0x00, 0x64, 0x0b},
+		"10.0.100.10":          []byte{0x00, 0x0a, 0x00, 0x00, 0x00, 0x64, 0x00, 0x0a},
+		"10.0.100.11":          []byte{0x0a, 0x00, 0x64, 0x0b},
+		"2001:504:0:2::6169:1": []byte{0x20, 0x01, 0x05, 0x04, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x61, 0x69, 0x00, 0x01},
 	}
 
 	for expt, in := range tests {
Repository: kentik/ktranslate
Pull request #548 (2023-03-24 00:05:20)

Fixing panic when variable tags are the empty string
There's a bug in how this variable mapping is applied. There's this loop here: 

```
            for tag, value := range dst.CustomStr {
                if tag == v[len(TagValuePrefix):] {
                    v = value
                }
            }
```

 the first time through, it will swap v to the value and everything is good. The problem is that the loop isn't exiting and v now is the empty string.

next time though, it will try to take a slice of the empty string and get your stack trace.
Code fix is to add a break statement so that once a correct variable is applied, no more variables will be swapped in.
for now, I'd recommend if possible you remove any of the $SysContact in tags for the offending containers
this should prevent the crash


Patch:
diff --git a/README.md b/README.md
index 7d2f93a..b7c6e8e 100644
--- a/README.md
+++ b/README.md
@@ -140,7 +140,7 @@ To get your own MaxMind key, visit [MaxMind](https://www.maxmind.com).
   -nr_estimate_only
     	If true, record size of inputs to NR but don't actually send anything
   -nr_region string
-    	NR Region to use. US|EU
+       NR Region to use. US|EU|GOV
   -olly_dataset string
     	Olly dataset name
   -olly_write_key string
diff --git a/pkg/inputs/snmp/metadata/poll.go b/pkg/inputs/snmp/metadata/poll.go
index 12d3caa..42f77b1 100644
--- a/pkg/inputs/snmp/metadata/poll.go
+++ b/pkg/inputs/snmp/metadata/poll.go
@@ -262,6 +262,7 @@ func (p *Poller) toFlows(dd *kt.DeviceData) ([]*kt.JCHF, error) {
 			for tag, value := range dst.CustomStr {
 				if tag == v[len(TagValuePrefix):] {
 					v = value
+					break // Once we find a match, break out and don't try comparing to anything else any more.
 				}
 			}
 		}


Test patch:
diff --git a/pkg/inputs/snmp/metadata/poll_test.go b/pkg/inputs/snmp/metadata/poll_test.go
index 8c71f43..22d2a47 100644
--- a/pkg/inputs/snmp/metadata/poll_test.go
+++ b/pkg/inputs/snmp/metadata/poll_test.go
@@ -40,3 +40,37 @@ func TestGetDeviceManufacturer(t *testing.T) {
 		}
 	}
 }
+
+func TestToFlows(t *testing.T) {
+	l := lt.NewTestContextL(logger.NilContext, t)
+	conf := &kt.SnmpDeviceConfig{
+		Provider: "foo",
+		UserTags: map[string]string{
+			"foo": "$foo",
+			"aaa": "$SysContact",
+		},
+	}
+	conf.InitUserTags("service")
+
+	p := &Poller{
+		log:  l,
+		conf: conf,
+	}
+
+	input := kt.DeviceData{
+		Manufacturer: "man",
+		DeviceMetricsMetadata: &kt.DeviceMetricsMetadata{
+			SysContact: "ddd",
+			Customs: map[string]string{
+				"foo": "",
+				"bar": "",
+			},
+		},
+	}
+	res, err := p.toFlows(&input)
+	assert.NotNil(t, res)
+	assert.Nil(t, err)
+	assert.Equal(t, 1, len(res))
+	assert.Equal(t, "ddd", res[0].CustomStr["tags.aaa"])
+	assert.Equal(t, "", res[0].CustomStr["tags.foo"]) // Empty string match for tag here.
+}