PrimeIntellect/SWE-rebench-V2-Filtered-Easy-Verified huggingface dataset:
Repository: GoogleChrome/sw-precache (js)
Issue: Defining a directory that doesn't exist
If you attempt to write to a path that doesn't exist at the time its run, swPrecache.write throws:

Error: ENOENT: no such file or directory, open '<Directory>/service-worker.js'
Pull request description: Use mkdirp to create parent directory inside write() if needed
R: @gauntface @addyosmani 

Closes #42 

Patch:
diff --git a/lib/sw-precache.js b/lib/sw-precache.js
index 79406ee..83f84e0 100644
--- a/lib/sw-precache.js
+++ b/lib/sw-precache.js
@@ -22,6 +22,7 @@ var defaults = require('lodash.defaults');
 var externalFunctions = require('./functions.js');
 var fs = require('fs');
 var glob = require('glob');
+var mkdirp = require('mkdirp');
 var path = require('path');
 var prettyBytes = require('pretty-bytes');
 var template = require('lodash.template');
@@ -196,6 +197,8 @@ function write(filePath, params, callback) {
       }
     }
 
+    mkdirp.sync(path.dirname(filePath));
+
     generate(params).then(function(serviceWorkerFileContents) {
       fs.writeFile(filePath, serviceWorkerFileContents, finish);
     }, finish);
diff --git a/package.json b/package.json
index e46832c..015e259 100644
--- a/package.json
+++ b/package.json
@@ -41,6 +41,7 @@
     "lodash.defaults": "^3.1.1",
     "lodash.template": "^3.6.1",
     "meow": "^3.3.0",
+    "mkdirp": "^0.5.1",
     "pretty-bytes": "^2.0.1"
   },
   "repository": "googlechrome/sw-precache",


Test patch:
diff --git a/test/test.js b/test/test.js
index 4e3ccf1..12d049c 100644
--- a/test/test.js
+++ b/test/test.js
@@ -21,6 +21,7 @@ var assert = require('assert');
 var externalFunctions = require('../lib/functions.js');
 var fs = require('fs');
 var generate = require('../lib/sw-precache.js').generate;
+var path = require('path');
 var write = require('../lib/sw-precache.js').write;
 
 var NOOP = function() {};
@@ -174,6 +175,27 @@ describe('sw-precache write functionality', function() {
   });
 });
 
+describe('sw-precache write functionality with missing parent directory', function() {
+  var SW_FILE = 'test/data/new_directory/generated_sw.js';
+
+  it('should write to disk, creating a new parent directory', function(done) {
+    write(SW_FILE, {logger: NOOP}, function(error) {
+      assert.ifError(error);
+      fs.stat(SW_FILE, function(error, stats) {
+        assert.ifError(error);
+        assert(stats.isFile(), 'file exists');
+        assert(stats.size > 0, 'file contains data');
+        done();
+      });
+    });
+  });
+
+  after(function() {
+    fs.unlinkSync(SW_FILE);
+    fs.rmdirSync(path.dirname(SW_FILE));
+  });
+});
+
 describe('sw-precache parameters', function() {
   it('should exclude files larger than maximumFileSizeToCacheInBytes', function(done) {
     var file = 'test/data/one/a.txt';
Repository: cayleygraph/cayley (go)
Issue: Gizmo: Type Assert All Values
**Description**
Currently, Gizmo will silently fail on values which are incorrectly formatted strings or hard fail with a weird error message for incorrect types. To reduce confusion values should be validated before execution.
Pull request description: Return error when calling filter() with a wrong type in Gizmo
We were not checking the argument type for `filter()` correctly. This PR adds this check. But if we want to accept string values, we will need another change, similar to how `has()` is implemented.

Fixes #833

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/cayleygraph/cayley/849)
<!-- Reviewable:end -->


Patch:
diff --git a/query/gizmo/traversals.go b/query/gizmo/traversals.go
index 7d710f8..e56e75b 100644
--- a/query/gizmo/traversals.go
+++ b/query/gizmo/traversals.go
@@ -17,6 +17,7 @@ package gizmo
 // Adds special traversal functions to JS Gizmo objects. Most of these just build the chain of objects, and won't often need the session.
 
 import (
+	"errors"
 	"fmt"
 
 	"github.com/dop251/goja"
@@ -644,6 +645,9 @@ func (p *pathObject) Filter(args ...valFilter) (*pathObject, error) {
 	}
 	filt := make([]shape.ValueFilter, 0, len(args))
 	for _, f := range args {
+		if f.f == nil {
+			return nil, errors.New("invalid argument type in filter()")
+		}
 		filt = append(filt, f.f)
 	}
 	np := p.clonePath().Filters(filt...)


Test patch:
diff --git a/query/gizmo/gizmo_test.go b/query/gizmo/gizmo_test.go
index 2bd3269..da192ff 100644
--- a/query/gizmo/gizmo_test.go
+++ b/query/gizmo/gizmo_test.go
@@ -193,6 +193,13 @@ var testQueries = []struct {
 		`,
 		expect: []string{"<charlie>"},
 	},
+	{
+		message: "filter with a wrong type",
+		query: `
+			g.V().filter(/<alice>/).all()
+		`,
+		err: true,
+	},
 	{
 		message: "use .both()",
 		query: `
Repository: not-fl3/nanoserde (rust)
Issue: Bug in parsing `#` token in TOML
Hi,

Thanks for a great library.

I use `nanoserde` to load configuration from a TOML file. That file contains some comments but `nanoserde` does not support comments in TOML yet.

Could you please add it? Or let me know if you want a PR.

Thanks
Pull request description: Fix bug in parsing `#` token in TOML
Close #61 

Patch:
diff --git a/src/toml.rs b/src/toml.rs
index c41cb9a..96f04b5 100644
--- a/src/toml.rs
+++ b/src/toml.rs
@@ -473,6 +473,14 @@ impl TomlParser {
                     while self.cur != '\n' && self.cur != '\0' {
                         self.next(i);
                     }
+
+                    while self.cur == '\n'
+                        || self.cur == '\r'
+                        || self.cur == '\t'
+                        || self.cur == ' '
+                    {
+                        self.next(i);
+                    }
                 }
                 '"' => {
                     let mut val = String::new();


Test patch:
diff --git a/tests/toml.rs b/tests/toml.rs
index a53ded8..7e2fda1 100644
--- a/tests/toml.rs
+++ b/tests/toml.rs
@@ -4,10 +4,11 @@ use nanoserde::TomlParser;
 fn de_toml() {
     let toml_str = r#"
 [[array]]
-name = "a"
+# a
+name = "a" #aasdf
 
 [[array]]
-name = "b"
+name = "b#asdf"
 data = 123
 
 [[array]]
@@ -24,7 +25,7 @@ hmm = "b"
     let toml = TomlParser::parse(toml_str).unwrap();
 
     assert_eq!(toml["array"].arr()[0]["name"].str(), "a");
-    assert_eq!(toml["array"].arr()[1]["name"].str(), "b");
+    assert_eq!(toml["array"].arr()[1]["name"].str(), "b#asdf");
     assert_eq!(toml["array"].arr()[1]["data"].num(), 123.);
 
     assert_eq!(toml["other_array"].arr()[0]["hmm"].str(), "a");