PrimeIntellect/SWE-rebench-V2-Filtered-Easy-Verified huggingface dataset:
Repository: nodeca/js-yaml (js)
Issue: Incorrect dump of block scalar with leading newlines and spaces
The following code dumps invalid YAML:

```js
console.log(yaml.safeDump({ str: '\n    a\nb' }))
```

Invalid output due to indentation:

```yaml
str: |-

      a
  b
```

Leading spaces are handled in general by an indentation indicator (below), but leading newlines seem to thwart this (above):

```js
console.log(yaml.safeDump({ str: '    a\nb' }))
```

Valid output:

```yaml
str: |2-
      a
  b
```

The results above are from version 3.11.0.
Pull request description: Check for leading newlines when determining if block indentation indicator is needed
Fixes #403

Patch:
diff --git a/lib/js-yaml/dumper.js b/lib/js-yaml/dumper.js
index 025b185..67cf6ca 100644
--- a/lib/js-yaml/dumper.js
+++ b/lib/js-yaml/dumper.js
@@ -234,6 +234,12 @@ function isPlainSafeFirst(c) {
     && c !== CHAR_GRAVE_ACCENT;
 }
 
+// Determines whether block indentation indicator is required.
+function needIndentIndicator(string) {
+  var leadingSpaceRe = /^\n* /;
+  return leadingSpaceRe.test(string);
+}
+
 var STYLE_PLAIN   = 1,
     STYLE_SINGLE  = 2,
     STYLE_LITERAL = 3,
@@ -301,7 +307,7 @@ function chooseScalarStyle(string, singleLineOnly, indentPerLevel, lineWidth, te
       ? STYLE_PLAIN : STYLE_SINGLE;
   }
   // Edge case: block indentation indicator can only have one digit.
-  if (string[0] === ' ' && indentPerLevel > 9) {
+  if (indentPerLevel > 9 && needIndentIndicator(string)) {
     return STYLE_DOUBLE;
   }
   // At this point we know block styles are valid.
@@ -365,7 +371,7 @@ function writeScalar(state, string, level, iskey) {
 
 // Pre-conditions: string is valid for a block scalar, 1 <= indentPerLevel <= 9.
 function blockHeader(string, indentPerLevel) {
-  var indentIndicator = (string[0] === ' ') ? String(indentPerLevel) : '';
+  var indentIndicator = needIndentIndicator(string) ? String(indentPerLevel) : '';
 
   // note the special case: the string '\n' counts as a "trailing" empty line.
   var clip =          string[string.length - 1] === '\n';


Test patch:
diff --git a/test/issues/0403.js b/test/issues/0403.js
new file mode 100644
index 0000000..43bc271
--- /dev/null
+++ b/test/issues/0403.js
@@ -0,0 +1,22 @@
+'use strict';
+
+
+var assert = require('assert');
+var yaml = require('../../');
+
+
+test('should properly dump leading newlines and spaces', function () {
+  var dump, src;
+
+  src = { str: '\n  a\nb' };
+  dump = yaml.dump(src);
+  assert.deepEqual(yaml.safeLoad(dump), src);
+
+  src = { str: '\n\n  a\nb' };
+  dump = yaml.dump(src);
+  assert.deepEqual(yaml.safeLoad(dump), src);
+
+  src = { str: '\n  a\nb' };
+  dump = yaml.dump(src, { indent: 10 });
+  assert.deepEqual(yaml.safeLoad(dump), src);
+});
Repository: pinojs/pino (js)
Issue: message not taking precedence over mergedObject
I'm creating a simple wrapper around Pino like that

```
const logger = pino({
  base: null,
  messageKey: 'message'
});

export default logger;
```

And I have `jest` test like that

```
it("should log an object", () => {
    const spy = jest.spyOn(process.stdout, "write");
    logger.info({ data: 123, test: true, message: "Message from mergingObject" }, "Message");

    expect(spy).toHaveBeenCalled();

    // Get the first argument of the first call
    const argument = spy.mock.calls[0][0];
    expect(argument).toBeTruthy();

    const data = JSON.parse(argument);
    expect(data.time).toBeGreaterThan(0);
    expect(data.v).toBeGreaterThan(0);
    expect(data.level).toEqual(30);
    expect(data.message).toEqual("Message");
  });
```

This test fails because of `data.message = Message from mergingObject`. But according to the docs

> The message parameter takes precedence over the mergedObject. That is, if a mergedObject contains a msg property, and a message parameter is supplied in addition, the msg property in the output log will be the value of the message parameter not the value of the msg property on the mergedObject.

Am I missing something or is it a bug?
Pull request description: Fix message precedence over mergedObject
Fixes #615 

Patch:
diff --git a/lib/tools.js b/lib/tools.js
index 92d44bc..41427eb 100644
--- a/lib/tools.js
+++ b/lib/tools.js
@@ -79,12 +79,11 @@ function asJson (obj, msg, num, time) {
   const chindings = this[chindingsSym]
   const serializers = this[serializersSym]
   var data = this[lsCacheSym][num] + time
-  if (msg !== undefined) {
-    data += messageKeyString + asString('' + msg)
-  }
+
   // we need the child bindings added to the output first so instance logged
   // objects can take precedence when JSON.parse-ing the resulting log line
   data = data + chindings
+
   var value
   if (hasObj === true) {
     var notHasOwnProperty = obj.hasOwnProperty === undefined
@@ -131,6 +130,11 @@ function asJson (obj, msg, num, time) {
       }
     }
   }
+
+  if (msg !== undefined) {
+    data += messageKeyString + asString('' + msg)
+  }
+
   return data + end
 }
 


Test patch:
diff --git a/test/basic.test.js b/test/basic.test.js
index f164f21..483b0cf 100644
--- a/test/basic.test.js
+++ b/test/basic.test.js
@@ -76,6 +76,24 @@ function levelTest (name, level) {
     })
   })
 
+  test(`overriding object key by string at level ${name}`, async ({ is, same }) => {
+    const stream = sink()
+    const instance = pino(stream)
+    instance.level = name
+    instance[name]({ hello: 'world', msg: 'object' }, 'string')
+    const result = await once(stream, 'data')
+    is(new Date(result.time) <= new Date(), true, 'time is greater than Date.now()')
+    delete result.time
+    same(result, {
+      pid: pid,
+      hostname: hostname,
+      level: level,
+      msg: 'string',
+      hello: 'world',
+      v: 1
+    })
+  })
+
   test(`formatting logs as ${name}`, async ({ is }) => {
     const stream = sink()
     const instance = pino(stream)