PrimeIntellect/SWE-rebench-V2 huggingface dataset:
Repository: go-resty/resty (go)

Issue:
Call to http.DetectContentType has trailing NUL bytes in buffer
In [`writeMultipartFormFile`](https://github.com/go-resty/resty/blob/v2/util.go#L211), the call to `http.DetectContentType` is passed a buffer with potentially trailing `0` bytes.  As a result, `text/plain` is never detected in such cases.

`cbuf` should be trimmed to `size` to ensure `text/plain` is property detected:

```go
// Auto detect actual multipart content type
cbuf := make([]byte, 512)
size, err := r.Read(cbuf)
if err != nil && err != io.EOF {
  return err
}

partWriter, err := w.CreatePart(createMultipartHeader(fieldName, fileName, http.DetectContentType(cbuf[:size])))
if err != nil {
  return err
}
```

Pull request:
fix: trailing NULL bytes in buffer while detecting a content type
Closes #754 

Patch:
diff --git a/util.go b/util.go
index 27b466d..5a69e4f 100644
--- a/util.go
+++ b/util.go
@@ -216,7 +216,7 @@ func writeMultipartFormFile(w *multipart.Writer, fieldName, fileName string, r i
 		return err
 	}
 
-	partWriter, err := w.CreatePart(createMultipartHeader(fieldName, fileName, http.DetectContentType(cbuf)))
+	partWriter, err := w.CreatePart(createMultipartHeader(fieldName, fileName, http.DetectContentType(cbuf[:size])))
 	if err != nil {
 		return err
 	}


Test patch:
diff --git a/middleware_test.go b/middleware_test.go
index f4e5c69..f5924cb 100644
--- a/middleware_test.go
+++ b/middleware_test.go
@@ -756,7 +756,7 @@ func Test_parseRequestBody(t *testing.T) {
 			expectedContentLength: "744",
 		},
 		{
-			name: "mulipart fields",
+			name: "multipart fields",
 			init: func(c *Client, r *Request) {
 				r.SetMultipartFields(
 					&MultipartField{
@@ -776,7 +776,7 @@ func Test_parseRequestBody(t *testing.T) {
 			expectedContentLength: "344",
 		},
 		{
-			name: "mulipart files",
+			name: "multipart files",
 			init: func(c *Client, r *Request) {
 				r.SetFileReader("foo", "foo.txt", strings.NewReader("1")).
 					SetFileReader("bar", "bar.txt", strings.NewReader("2")).
@@ -784,7 +784,7 @@ func Test_parseRequestBody(t *testing.T) {
 			},
 			expectedBodyBuf:       []byte(`{"bar":"2","foo":"1"}`),
 			expectedContentType:   "multipart/form-data; boundary=",
-			expectedContentLength: "412",
+			expectedContentLength: "414",
 		},
 		{
 			name: "body with errorReader",
Repository: yargs/yargs (js)

Issue:
Bash completion with Positional Arguments
- command: `exports.command = 'test <dir>';`
- exec: `node bin.js --get-yargs-completions`
- output: `test <dir>`
- then the bash completion will output  `test` and `<dir>`

[completion](https://github.com/yargs/yargs/blob/master/lib/completion.js#L59) should be `command[0].split('  ')[0]`

Pull request:
BugFix: Exclude positional arguments from completion output
Fixes #818 + Added test

Patch:
diff --git a/lib/completion.js b/lib/completion.js
index ba23d43..1cbd796 100644
--- a/lib/completion.js
+++ b/lib/completion.js
@@ -55,9 +55,10 @@ module.exports = function completion (yargs, usage, command) {
     }
 
     if (!current.match(/^-/)) {
-      usage.getCommands().forEach((command) => {
-        if (args.indexOf(command[0]) === -1) {
-          completions.push(command[0])
+      usage.getCommands().forEach((usageCommand) => {
+        const commandName = command.parseCommand(usageCommand[0]).cmd
+        if (args.indexOf(commandName) === -1) {
+          completions.push(commandName)
         }
       })
     }


Test patch:
diff --git a/test/completion.js b/test/completion.js
index 71cf571..eb80c30 100644
--- a/test/completion.js
+++ b/test/completion.js
@@ -121,6 +121,20 @@ describe('Completion', () => {
       r.logs.should.include('cmd1')
     })
 
+    it('does not include possitional arguments', function () {
+      var r = checkUsage(function () {
+        return yargs(['./completion', '--get-yargs-completions', 'cmd'])
+          .command('cmd1 [arg]', 'first command')
+          .command('cmd2 <arg>', 'second command')
+          .completion('completion', false)
+          .argv
+      })
+
+      r.logs.should.have.length(2)
+      r.logs.should.include('cmd1')
+      r.logs.should.include('cmd2')
+    })
+
     it('works if command has no options', () => {
       const r = checkUsage(() => yargs(['./completion', '--get-yargs-completions', 'foo', '--b'])
           .help(false)