nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: MiSawa/xq
Pull request #144 (2022-04-24 02:31:18)

Fix deletion of negative index of array out of range
Deletion of paths with negative index out of range should not raise error.
```sh
❯ jq -n '[1,2,3] | del(.[-10])'
[
  1,
  2,
  3
]

❯ xq -n '[1,2,3] | del(.[-10])'
Error: InvalidIndex(-10)
```


Patch:
diff --git a/src/intrinsic/path.rs b/src/intrinsic/path.rs
index 5f974b1..9218e6e 100644
--- a/src/intrinsic/path.rs
+++ b/src/intrinsic/path.rs
@@ -224,7 +224,7 @@ fn replace_tombstone_rec(context: Value, path: &[Value], placeholder: Value) ->
                     .to_isize()
                     .ok_or_else(|| QueryExecutionError::InvalidIndex(index.clone()))?;
                 if i + (arr.len() as isize) < 0 {
-                    return Err(QueryExecutionError::InvalidIndex(index.clone()));
+                    return Ok(arr.into());
                 }
                 let i = if i < 0 {
                     (i + arr.len() as isize) as usize


Test patch:
diff --git a/tests/hand_written/mod.rs b/tests/hand_written/mod.rs
index 468bf43..bcffe70 100644
--- a/tests/hand_written/mod.rs
+++ b/tests/hand_written/mod.rs
@@ -669,6 +669,19 @@ test!(
 test!(
     delete3,
     r#"
+    {x:[1]} | del(.x[-2,-1,2])
+    "#,
+    r#"
+    null
+    "#,
+    r#"
+    {"x":[]}
+    "#
+);
+
+test!(
+    delete4,
+    r#"
     try ({x:[1]} | del(.x.y, .x[0], .x)) catch "err"
     "#,
     r#"
@@ -680,7 +693,7 @@ test!(
 );
 
 test!(
-    delete4,
+    delete5,
     r#"
     try ({x:[1]} | del(.x[0], .x.y, .x)) catch "err"
     "#,
Repository: MiSawa/xq
Pull request #154 (2022-09-04 00:34:14)

Fix path tracking on value arguments
I received a bug report to gojq (https://github.com/itchyny/gojq/issues/186). This bug is reproducible in xq as well. I fixed the bug.
```
 $ xq -n 'def f($x): .y; path(f(.x))'
[
  "x",
  "y"
]
 $ jq -n 'def f($x): .y; path(f(.x))'
[
  "y"
]
```


Patch:
diff --git a/src/compile/compiler.rs b/src/compile/compiler.rs
index f8d9433..a37a320 100644
--- a/src/compile/compiler.rs
+++ b/src/compile/compiler.rs
@@ -663,6 +663,9 @@ impl Compiler {
                         .emit_normal_op(ByteCode::PushClosure(closure), next);
                 }
                 ArgType::Value => {
+                    next = self
+                        .emitter
+                        .emit_normal_op(ByteCode::ExitNonPathTracking, next);
                     if require_context {
                         next = self.emitter.emit_normal_op(ByteCode::Swap, next);
                     }
@@ -672,6 +675,9 @@ impl Compiler {
                     } else {
                         require_context = true;
                     }
+                    next = self
+                        .emitter
+                        .emit_normal_op(ByteCode::EnterNonPathTracking, next);
                 }
             }
         }


Test patch:
diff --git a/tests/hand_written/mod.rs b/tests/hand_written/mod.rs
index bcffe70..c26b79b 100644
--- a/tests/hand_written/mod.rs
+++ b/tests/hand_written/mod.rs
@@ -877,3 +877,16 @@ test!(
     "🤔"
     "#
 );
+
+test!(
+    path_value_argument,
+    r#"
+    def f($x): .y; path(f(.x))
+    "#,
+    r#"
+    null
+    "#,
+    r#"
+    ["y"]
+    "#
+);
Repository: moira-alert/moira
Pull request #1107 (2024-09-27 09:36:49)

refactor: hide credentials in tg sender
# PR Summary

Package telebot used in tg sender has internal logging, and when error occurs it writes uri (**with token!**) to logs.

This PR fixes it.


Patch:
diff --git a/senders/telegram/init.go b/senders/telegram/init.go
index 4659c1f6..aabd2a4f 100644
--- a/senders/telegram/init.go
+++ b/senders/telegram/init.go
@@ -80,8 +80,9 @@ func (sender *Sender) Init(senderSettings interface{}, logger moira.Logger, loca
 
 	sender.logger = logger
 	sender.bot, err = telebot.NewBot(telebot.Settings{
-		Token:  cfg.APIToken,
-		Poller: &telebot.LongPoller{Timeout: pollerTimeout},
+		Token:   cfg.APIToken,
+		Poller:  &telebot.LongPoller{Timeout: pollerTimeout},
+		OnError: sender.customOnErrorFunc,
 	})
 	if err != nil {
 		return sender.removeTokenFromError(err)
@@ -123,3 +124,13 @@ func (sender *Sender) runTelebot(contactType string) {
 func telegramLockKey(contactType string) string {
 	return telegramLockPrefix + contactType
 }
+
+const errorInsideTelebotMsg = "Error inside telebot"
+
+func (sender *Sender) customOnErrorFunc(err error, _ telebot.Context) {
+	err = sender.removeTokenFromError(err)
+
+	sender.logger.Warning().
+		Error(err).
+		Msg(errorInsideTelebotMsg)
+}


Test patch:
diff --git a/senders/telegram/init_test.go b/senders/telegram/init_test.go
index f55cdfcd..9179cb92 100644
--- a/senders/telegram/init_test.go
+++ b/senders/telegram/init_test.go
@@ -1,10 +1,15 @@
 package telegram
 
 import (
+	"errors"
 	"fmt"
+	"strings"
 	"testing"
 	"time"
 
+	mock_moira_alert "github.com/moira-alert/moira/mock/moira-alert"
+	"go.uber.org/mock/gomock"
+
 	logging "github.com/moira-alert/moira/logging/zerolog_adapter"
 	. "github.com/smartystreets/goconvey/convey"
 )
@@ -31,3 +36,26 @@ func TestInit(t *testing.T) {
 		})
 	})
 }
+
+func Test_customOnErrorFunc(t *testing.T) {
+	Convey("test customOnErrorFunc hides credential and logs", t, func() {
+		mockCtrl := gomock.NewController(t)
+		defer mockCtrl.Finish()
+
+		logger := mock_moira_alert.NewMockLogger(mockCtrl)
+		eventsBuilder := mock_moira_alert.NewMockEventBuilder(mockCtrl)
+
+		sender := Sender{
+			logger:   logger,
+			apiToken: "1111111111:SecretTokenabc_987654321hellokonturmoira",
+		}
+
+		err := fmt.Errorf("https://some.api.of.telegram/bot%s/update failed to update", sender.apiToken)
+
+		logger.EXPECT().Warning().Return(eventsBuilder).AnyTimes()
+		eventsBuilder.EXPECT().Error(errors.New(strings.ReplaceAll(err.Error(), sender.apiToken, hidden))).Return(eventsBuilder)
+		eventsBuilder.EXPECT().Msg(errorInsideTelebotMsg)
+
+		sender.customOnErrorFunc(err, nil)
+	})
+}