nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: jhipster/generator-jhipster
Pull request #9105 (2019-01-20 23:15:22)

Don't define unnecessary node.version and npm.version properties if skipClient
-   Please make sure the below checklist is followed for Pull Requests.

-   [ ] [Travis tests](https://travis-ci.org/jhipster/generator-jhipster/pull_requests) are green
-   [ ] Tests are added where necessary
-   [ ] Documentation is added/updated where necessary
-   [ ] Coding Rules & Commit Guidelines as per our [CONTRIBUTING.md document](https://github.com/jhipster/generator-jhipster/blob/master/CONTRIBUTING.md) are followed

<!--
Please also reference the issue number in a commit message to [automatically close the related Github issue](https://help.github.com/articles/closing-issues-via-commit-messages/)

Note: It is also possible to add `[skip ci]` to your commit message to skip Travis tests
-->



Patch:
diff --git a/generators/server/templates/pom.xml.ejs b/generators/server/templates/pom.xml.ejs
index 5772c4314a..6854a72ed6 100644
--- a/generators/server/templates/pom.xml.ejs
+++ b/generators/server/templates/pom.xml.ejs
@@ -54,12 +54,14 @@
         <maven.version>3.0.0</maven.version>
         <java.version><%= JAVA_VERSION %></java.version>
         <scala.version><%= SCALA_VERSION %></scala.version>
+        <%_ if (!skipClient) { _%>
         <node.version>v<%= NODE_VERSION %></node.version>
-        <%_ if (clientPackageManager === 'npm') { _%>
+            <%_ if (clientPackageManager === 'npm') { _%>
         <npm.version><%= NPM_VERSION %></npm.version>
-        <%_ } _%>
-        <%_ if (clientPackageManager === 'yarn') { _%>
+            <%_ } _%>
+            <%_ if (clientPackageManager === 'yarn') { _%>
         <yarn.version>v<%= YARN_VERSION %></yarn.version>
+            <%_ } _%>
         <%_ } _%>
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
         <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>


Test patch:
diff --git a/test/app.spec.js b/test/app.spec.js
index 54a6903ef6..36e8940e3b 100644
--- a/test/app.spec.js
+++ b/test/app.spec.js
@@ -1423,6 +1423,11 @@ describe('JHipster generator', () => {
             it('generates a README with no undefined value', () => {
                 assert.noFileContent('README.md', /undefined/);
             });
+            it('generates a pom.xml with no reference to client', () => {
+                assert.noFileContent('pom.xml', 'node.version');
+                assert.noFileContent('pom.xml', 'npm.version');
+                assert.noFileContent('pom.xml', 'frontend-maven-plugin');
+            });
         });
 
         describe('Gradle', () => {
Repository: parse-community/Parse-SDK-JS
Pull request #662 (2018-09-14 13:54:47)

LiveQuery Support for Subclasses
Closes: https://github.com/parse-community/Parse-SDK-JS/issues/372, https://github.com/parse-community/Parse-SDK-JS/issues/340, https://github.com/parse-community/Parse-SDK-JS/issues/595




Patch:
diff --git a/src/LiveQueryClient.js b/src/LiveQueryClient.js
index 6f713ce..9904e3a 100644
--- a/src/LiveQueryClient.js
+++ b/src/LiveQueryClient.js
@@ -389,12 +389,10 @@ class LiveQueryClient extends EventEmitter {
       break;
     default: {
       // create, update, enter, leave, delete cases
-      const className = data.object.className;
-      // Delete the extrea __type and className fields during transfer to full JSON
+
+      // Does not override / clear server data
       delete data.object.__type;
-      delete data.object.className;
-      const parseObject = new ParseObject(className);
-      parseObject._finishFetch(data.object);
+      const parseObject = ParseObject.fromJSON(data.object, false);
       if (!subscription) {
         break;
       }


Test patch:
diff --git a/src/__tests__/LiveQueryClient-test.js b/src/__tests__/LiveQueryClient-test.js
index b8c6519..6c289d7 100644
--- a/src/__tests__/LiveQueryClient-test.js
+++ b/src/__tests__/LiveQueryClient-test.js
@@ -416,4 +416,44 @@ describe('LiveQueryClient', () => {
     expect(liveQueryClient.socket.close).toBeCalled();
     expect(liveQueryClient.state).toBe('disconnected');
   });
+
+  it('can handle WebSocket subclass', () => {
+    const MyExtendedClass = ParseObject.extend('MyExtendedClass');
+    ParseObject.registerSubclass('MyExtendedClass', MyExtendedClass);
+
+    const liveQueryClient = new LiveQueryClient({
+      applicationId: 'applicationId',
+      serverURL: 'ws://test',
+      javascriptKey: 'javascriptKey',
+      masterKey: 'masterKey',
+      sessionToken: 'sessionToken'
+    });
+    // Add mock subscription
+    const subscription = new events.EventEmitter();
+    liveQueryClient.subscriptions.set(1, subscription);
+    const object = new MyExtendedClass();
+    object.set('key', 'value');
+    const data = {
+      op: 'create',
+      clientId: 1,
+      requestId: 1,
+      object: object._toFullJSON(),
+    };
+    const event = {
+      data: JSON.stringify(data)
+    }
+    // Register checked in advance
+    let isChecked = false;
+    subscription.on('create', function(parseObject) {
+      isChecked = true;
+      expect(parseObject instanceof MyExtendedClass).toBe(true);
+      expect(parseObject.get('key')).toEqual('value');
+      expect(parseObject.get('className')).toBeUndefined();
+      expect(parseObject.get('__type')).toBeUndefined();
+    });
+
+    liveQueryClient._handleWebSocketMessage(event);
+
+    expect(isChecked).toBe(true);
+  });
 });
Repository: parse-community/Parse-SDK-JS
Pull request #682 (2018-10-21 00:16:53)

Handle undefined in Cloud Code
Closes https://github.com/parse-community/Parse-SDK-JS/issues/417

Based on discussion https://github.com/parse-community/parse-server/issues/5053

Previously threw Invalid response and unhandled promise rejection


Patch:
diff --git a/integration/cloud/main.js b/integration/cloud/main.js
index d677209..e154374 100644
--- a/integration/cloud/main.js
+++ b/integration/cloud/main.js
@@ -7,6 +7,10 @@ Parse.Cloud.define("bar", function(request) {
   }
 });
 
+Parse.Cloud.define('CloudFunctionUndefined', function() {
+  return undefined;
+});
+
 Parse.Cloud.job('CloudJob1', function() {
   return {
     status: 'cloud job completed'
diff --git a/src/Cloud.js b/src/Cloud.js
index 09d90e5..c147a1d 100644
--- a/src/Cloud.js
+++ b/src/Cloud.js
@@ -122,14 +122,19 @@ const DefaultController = {
     );
 
     return request.then((res) => {
+      if (typeof res === 'object' &&
+          Object.keys(res).length > 0 &&
+          !res.hasOwnProperty('result')) {
+        throw new ParseError(
+          ParseError.INVALID_JSON,
+          'The server returned an invalid response.'
+        );
+      }
       const decoded = decode(res);
       if (decoded && decoded.hasOwnProperty('result')) {
         return Promise.resolve(decoded.result);
       }
-      throw new ParseError(
-        ParseError.INVALID_JSON,
-        'The server returned an invalid response.'
-      );
+      return Promise.resolve(undefined);
     });
   },
 


Test patch:
diff --git a/integration/test/ParseCloudTest.js b/integration/test/ParseCloudTest.js
index 062e12f..42770a8 100644
--- a/integration/test/ParseCloudTest.js
+++ b/integration/test/ParseCloudTest.js
@@ -70,6 +70,13 @@ describe('Parse Cloud', () => {
     }
   });
 
+  it('run function with undefined', (done) => {
+    Parse.Cloud.run('CloudFunctionUndefined', {}).then((result) => {
+      assert.strictEqual(result, undefined);
+      done();
+    });
+  });
+
   it('run job', (done) => {
     const params = { startedBy: 'Monty Python' };
     Parse.Cloud.startJob('CloudJob1', params).then((jobStatusId) => {
diff --git a/src/__tests__/Cloud-test.js b/src/__tests__/Cloud-test.js
index b8e083b..2a5b9bf 100644
--- a/src/__tests__/Cloud-test.js
+++ b/src/__tests__/Cloud-test.js
@@ -162,6 +162,18 @@ describe('CloudController', () => {
     });
   });
 
+  it('run undefined response', (done) => {
+    const request = jest.fn();
+    request.mockReturnValue(Promise.resolve(undefined));
+
+    const ajax = jest.fn();
+    CoreManager.setRESTController({ request: request, ajax: ajax });
+
+    Cloud.run('myfunction').then(() => {
+      done();
+    });
+  });
+
   it('startJob passes encoded requests', () => {
     Cloud.startJob('myJob', { value: 12, when: new Date(Date.UTC(2015,0,1)) });
Repository: tetratelabs/wazero
Pull request #282 (2022-02-23 09:28:05)

Restores ModuleConfig.WithName to support cloned Wasm
PR #281 allowed repetitive use of the same module config to avoid
re-decoding the same wasm. However, it is possible that configuration is
renamed in separate goroutines. This makes caching safer by restoring
the `WithName` function deleted earlier. By using this, a configuration
and its cache state are cloned, and doing that is thread safe.



Patch:
diff --git a/wasm.go b/wasm.go
index acfdab11..5736cf8d 100644
--- a/wasm.go
+++ b/wasm.go
@@ -78,6 +78,16 @@ func (m *ModuleConfig) Validate() (err error) {
 	return err
 }
 
+// WithName returns a new instance which overrides the Name, but keeps any internal cache made by Validate.
+func (m *ModuleConfig) WithName(moduleName string) *ModuleConfig {
+	return &ModuleConfig{
+		Name:            moduleName,
+		Source:          m.Source,
+		validatedSource: m.validatedSource,
+		decodedModule:   m.decodedModule,
+	}
+}
+
 // InstantiateModule instantiates the module namespace or errs if the configuration was invalid.
 //
 // Ex.


Test patch:
diff --git a/wasm_test.go b/wasm_test.go
index 0231d6c4..b6b313fa 100644
--- a/wasm_test.go
+++ b/wasm_test.go
@@ -55,8 +55,12 @@ func TestDecodeModule(t *testing.T) {
 
 		again, _, err := decodeModule(config)
 		require.NoError(t, err)
-
 		require.Same(t, m, again)
+
+		// Ensure config that only changes the name doesn't have to re-decode the source.
+		cloned, _, err := decodeModule(config.WithName("wazero"))
+		require.NoError(t, err)
+		require.Same(t, m, cloned)
 	})
 
 	t.Run("changing source invalidates decode cache", func(t *testing.T) {
@@ -64,12 +68,19 @@ func TestDecodeModule(t *testing.T) {
 		m, _, err := decodeModule(config)
 		require.NoError(t, err)
 
+		clonedConfig := config.WithName("wazero")
+
+		// When the source is changed, the module needs to be decoded again
 		config.Source = wasm
 		again, _, err := decodeModule(config)
 		require.NoError(t, err)
-
 		require.Equal(t, m, again)
 		require.NotSame(t, m, again)
+
+		// Any copies of the config shouldn't be invalidated
+		cloned, _, err := decodeModule(clonedConfig)
+		require.NoError(t, err)
+		require.Same(t, m, cloned)
 	})
 }
Repository: tetratelabs/wazero
Pull request #359 (2022-03-11 02:21:50)

Fix duplicated increments on dependantCounts.
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>


Patch:
diff --git a/internal/wasm/store.go b/internal/wasm/store.go
index 1bb07729..406997aa 100644
--- a/internal/wasm/store.go
+++ b/internal/wasm/store.go
@@ -502,8 +502,10 @@ func (s *Store) resolveImports(module *Module) (
 			return
 		}
 
-		m.incDependentCount() // TODO: check if the module is already released. See #293
-		moduleImports[m] = struct{}{}
+		if _, ok := moduleImports[m]; !ok {
+			m.incDependentCount() // TODO: check if the module is already released. See #293
+			moduleImports[m] = struct{}{}
+		}
 
 		var imported *ExportInstance
 		imported, err = m.getExport(i.Name, i.Type)


Test patch:
diff --git a/internal/wasm/store_test.go b/internal/wasm/store_test.go
index 23e67973..6bf639c4 100644
--- a/internal/wasm/store_test.go
+++ b/internal/wasm/store_test.go
@@ -601,17 +601,27 @@ func TestStore_resolveImports(t *testing.T) {
 		t.Run("ok", func(t *testing.T) {
 			s := newStore()
 			f := &FunctionInstance{Type: &FunctionType{Results: []ValueType{ValueTypeF32}}}
-			s.modules[moduleName] = &ModuleInstance{Exports: map[string]*ExportInstance{name: {
-				Function: f,
-			}}, Name: moduleName}
+			g := &FunctionInstance{Type: &FunctionType{Results: []ValueType{ValueTypeI32}}}
+			s.modules[moduleName] = &ModuleInstance{
+				Exports: map[string]*ExportInstance{
+					name: {Function: f},
+					"":   {Function: g},
+				},
+				Name: moduleName,
+			}
 			m := &Module{
-				TypeSection:   []*FunctionType{{Results: []ValueType{ValueTypeF32}}},
-				ImportSection: []*Import{{Module: moduleName, Name: name, Type: ExternTypeFunc, DescFunc: 0}},
+				TypeSection: []*FunctionType{{Results: []ValueType{ValueTypeF32}}, {Results: []ValueType{ValueTypeI32}}},
+				ImportSection: []*Import{
+					{Module: moduleName, Name: name, Type: ExternTypeFunc, DescFunc: 0},
+					{Module: moduleName, Name: "", Type: ExternTypeFunc, DescFunc: 1},
+				},
 			}
 			functions, _, _, _, moduleImports, err := s.resolveImports(m)
 			require.NoError(t, err)
 			require.Contains(t, moduleImports, s.modules[moduleName])
 			require.Contains(t, functions, f)
+			require.Contains(t, functions, g)
+			// DependentCount must be one even when importing two instances.
 			require.Equal(t, 1, s.modules[moduleName].dependentCount)
 		})
 		t.Run("type out of range", func(t *testing.T) {
Repository: tetratelabs/wazero
Pull request #369 (2022-03-14 10:29:35)

Fix overflow on MemoryInstance.hasSize
This PR fixes a bug on bound checking of a memory instance.

Signed-off-by: Takaya Saeki <abc.tkys+pub@gmail.com>

nullpo-head: I've noticed that my email and sign are my personal one's because of the new PC setup. Fixing it.

Patch:
diff --git a/internal/wasm/memory.go b/internal/wasm/memory.go
index 99d2215d..9f62db30 100644
--- a/internal/wasm/memory.go
+++ b/internal/wasm/memory.go
@@ -35,7 +35,7 @@ func (m *MemoryInstance) Size() uint32 {
 
 // hasSize returns true if Len is sufficient for sizeInBytes at the given offset.
 func (m *MemoryInstance) hasSize(offset uint32, sizeInBytes uint32) bool {
-	return uint64(offset+sizeInBytes) <= uint64(m.Size()) // uint64 prevents overflow on add
+	return uint64(offset)+uint64(sizeInBytes) <= uint64(m.Size()) // uint64 prevents overflow on add
 }
 
 // ReadByte implements wasm.Memory ReadByte


Test patch:
diff --git a/internal/wasm/memory_test.go b/internal/wasm/memory_test.go
index 8ea2cdb6..50535d35 100644
--- a/internal/wasm/memory_test.go
+++ b/internal/wasm/memory_test.go
@@ -89,7 +89,7 @@ func TestWriteUint32Le(t *testing.T) {
 	require.False(t, mem.WriteUint32Le(9, 16))
 }
 
-func TestMemoryInstance_HasLen(t *testing.T) {
+func TestMemoryInstance_HasSize(t *testing.T) {
 	memory := &MemoryInstance{Buffer: make([]byte, 100)}
 
 	tests := []struct {
@@ -122,6 +122,12 @@ func TestMemoryInstance_HasLen(t *testing.T) {
 			sizeInBytes: 1, // arbitrary size
 			expected:    false,
 		},
+		{
+			name:        "offset + sizeInBytes overflows in uint32",
+			offset:      math.MaxUint32 - 1, // invalid too large offset
+			sizeInBytes: 4,                  // if there's overflow, offset + sizeInBytes is 3, and it may pass the check
+			expected:    false,
+		},
 	}
 
 	for _, tt := range tests {