nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: slack-go/slack
Pull request #1131 (2022-11-22 04:17:44)

fix: change type of timestamp
## why
I saw the issues on https://github.com/slack-go/slack/issues/1123 and https://github.com/slack-go/slack/issues/1104.
I fixed them.

## what
I changed the Timestamp defined in RichTextSectionDateElement to a JSONTime type.
I also added the case of RichTextSectionDateElement to the test.


Patch:
diff --git a/block_rich_text.go b/block_rich_text.go
index 281db21..555a619 100644
--- a/block_rich_text.go
+++ b/block_rich_text.go
@@ -327,17 +327,17 @@ func NewRichTextSectionUserGroupElement(usergroupID string) *RichTextSectionUser
 
 type RichTextSectionDateElement struct {
 	Type      RichTextSectionElementType `json:"type"`
-	Timestamp string                     `json:"timestamp"`
+	Timestamp JSONTime                   `json:"timestamp"`
 }
 
 func (r RichTextSectionDateElement) RichTextSectionElementType() RichTextSectionElementType {
 	return r.Type
 }
 
-func NewRichTextSectionDateElement(timestamp string) *RichTextSectionDateElement {
+func NewRichTextSectionDateElement(timestamp int64) *RichTextSectionDateElement {
 	return &RichTextSectionDateElement{
 		Type:      RTSEDate,
-		Timestamp: timestamp,
+		Timestamp: JSONTime(timestamp),
 	}
 }
 


Test patch:
diff --git a/block_rich_text_test.go b/block_rich_text_test.go
index 4c889eb..270dde9 100644
--- a/block_rich_text_test.go
+++ b/block_rich_text_test.go
@@ -80,12 +80,13 @@ func TestRichTextSection_UnmarshalJSON(t *testing.T) {
 		err      error
 	}{
 		{
-			[]byte(`{"elements":[{"type":"unknown","value":10},{"type":"text","text":"hi"}]}`),
+			[]byte(`{"elements":[{"type":"unknown","value":10},{"type":"text","text":"hi"},{"type":"date","timestamp":1636961629}]}`),
 			RichTextSection{
 				Type: RTESection,
 				Elements: []RichTextSectionElement{
 					&RichTextSectionUnknownElement{Type: RTSEUnknown, Raw: `{"type":"unknown","value":10}`},
 					&RichTextSectionTextElement{Type: RTSEText, Text: "hi"},
+					&RichTextSectionDateElement{Type: RTSEDate, Timestamp: JSONTime(1636961629)},
 				},
 			},
 			nil,
Repository: slack-go/slack
Pull request #1273 (2024-03-15 15:20:37)

Block Object: Validate text min and max length
The validate block wasn't validating the text size. This was generating a confusing `invalid_block` error when we were sending a message that was longer than the allowed max value, even though we were calling validate() before sending.

Adds:
- Text field min size validation of 1
- Text field max size validation of 3000
- Tests for both cases


Patch:
diff --git a/block_object.go b/block_object.go
index b39ff22..a3e78d4 100644
--- a/block_object.go
+++ b/block_object.go
@@ -147,6 +147,16 @@ func (s TextBlockObject) Validate() error {
 		return errors.New("emoji cannot be true in mrkdown")
 	}
 
+	// https://api.slack.com/reference/block-kit/composition-objects#text__fields
+	if len(s.Text) == 0 {
+		return errors.New("text must have a minimum length of 1")
+	}
+
+	// https://api.slack.com/reference/block-kit/composition-objects#text__fields
+	if len(s.Text) > 3000 {
+		return errors.New("text cannot be longer than 3000 characters")
+	}
+
 	return nil
 }
 


Test patch:
diff --git a/block_object_test.go b/block_object_test.go
index 9889fae..1f4874a 100644
--- a/block_object_test.go
+++ b/block_object_test.go
@@ -2,6 +2,7 @@ package slack
 
 import (
 	"errors"
+	"strings"
 	"testing"
 
 	"github.com/stretchr/testify/assert"
@@ -126,6 +127,24 @@ func TestValidateTextBlockObject(t *testing.T) {
 			},
 			expected: errors.New("emoji cannot be true in mrkdown"),
 		},
+		{
+			input: TextBlockObject{
+				Type:     "mrkdwn",
+				Text:     "",
+				Emoji:    false,
+				Verbatim: false,
+			},
+			expected: errors.New("text must have a minimum length of 1"),
+		},
+		{
+			input: TextBlockObject{
+				Type:     "mrkdwn",
+				Text:     strings.Repeat("a", 3001),
+				Emoji:    false,
+				Verbatim: false,
+			},
+			expected: errors.New("text cannot be longer than 3000 characters"),
+		},
 	}
 
 	for _, test := range tests {
Repository: slack-go/slack
Pull request #1278 (2024-04-18 19:14:55)

Add missing message option for link_names
This adds a missing optional parameter to the `chat.postMessage` API (https://api.slack.com/methods/chat.postMessage#arg_link_names)


Patch:
diff --git a/chat.go b/chat.go
index 35ffbbc..2668b38 100644
--- a/chat.go
+++ b/chat.go
@@ -696,6 +696,14 @@ func MsgOptionMetadata(metadata SlackMetadata) MsgOption {
 	}
 }
 
+// MsgOptionLinkNames finds and links user groups. Does not support linking individual users
+func MsgOptionLinkNames(linkName bool) MsgOption {
+	return func(config *sendConfig) error {
+		config.values.Set("link_names", strconv.FormatBool(linkName))
+		return nil
+	}
+}
+
 // UnsafeMsgOptionEndpoint deliver the message to the specified endpoint.
 // NOTE: USE AT YOUR OWN RISK: No issues relating to the use of this Option
 // will be supported by the library, it is subject to change without notice that


Test patch:
diff --git a/chat_test.go b/chat_test.go
index fb37225..ee93bdd 100644
--- a/chat_test.go
+++ b/chat_test.go
@@ -185,6 +185,28 @@ func TestPostMessage(t *testing.T) {
 				"user_auth_message": []string{"Please!"},
 			},
 		},
+		"LinkNames true": {
+			endpoint: "/chat.postMessage",
+			opt: []MsgOption{
+				MsgOptionLinkNames(true),
+			},
+			expected: url.Values{
+				"channel":    []string{"CXXX"},
+				"token":      []string{"testing-token"},
+				"link_names": []string{"true"},
+			},
+		},
+		"LinkNames false": {
+			endpoint: "/chat.postMessage",
+			opt: []MsgOption{
+				MsgOptionLinkNames(false),
+			},
+			expected: url.Values{
+				"channel":    []string{"CXXX"},
+				"token":      []string{"testing-token"},
+				"link_names": []string{"false"},
+			},
+		},
 	}
 
 	once.Do(startServer)