nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: dherault/serverless-offline
Pull request #697 (2019-06-08 08:01:18)

Add requestTimeEpoch to requestContext
Add requestTimeEpoch to requestContext


Patch:
diff --git a/package.json b/package.json
index a919dcdf..f652a304 100644
--- a/package.json
+++ b/package.json
@@ -124,7 +124,8 @@
     "Alessandro Palumbo (https://github.com/apalumbo)",
     "Selcuk Cihan (https://github.com/selcukcihan)",
     "G Roques (https://github.com/gbroques)",
-    "Dustin Belliston (https://github.com/dwbelliston)"
+    "Dustin Belliston (https://github.com/dwbelliston)",
+    "kobanyan (https://github.com/kobanyan)"
   ],
   "dependencies": {
     "@hapi/boom": "^7.4.2",
diff --git a/src/createLambdaProxyContext.js b/src/createLambdaProxyContext.js
index d0b319f3..d85b8b94 100644
--- a/src/createLambdaProxyContext.js
+++ b/src/createLambdaProxyContext.js
@@ -98,6 +98,7 @@ module.exports = function createLambdaProxyContext(request, options, stageVariab
       protocol: 'HTTP/1.1',
       resourcePath: request.route.path,
       httpMethod: request.method.toUpperCase(),
+      requestTimeEpoch: request.info.received,
     },
     resource: request.route.path,
     httpMethod: request.method.toUpperCase(),


Test patch:
diff --git a/test/support/RequestBuilder.js b/test/support/RequestBuilder.js
index 315c521a..270c14a3 100644
--- a/test/support/RequestBuilder.js
+++ b/test/support/RequestBuilder.js
@@ -14,6 +14,7 @@ module.exports = class RequestBuilder {
       rawPayload: null,
       info: {
         remoteAddress: '127.0.0.1',
+        received: 1,
       },
     };
   }
diff --git a/test/unit/createLambdaProxyContextTest.js b/test/unit/createLambdaProxyContextTest.js
index 2d24f773..49cee738 100644
--- a/test/unit/createLambdaProxyContextTest.js
+++ b/test/unit/createLambdaProxyContextTest.js
@@ -18,6 +18,7 @@ describe('createLambdaProxyContext', () => {
     expect(requestContext.identity.userArn).to.eq('offlineContext_userArn');
     expect(requestContext.identity.user).to.eq('offlineContext_user');
     expect(requestContext.authorizer.principalId).to.eq('offlineContext_authorizer_principalId');
+    expect(requestContext.requestTimeEpoch).to.eq(1);
   };
 
   const stageVariables = {};
Repository: erikras/redux-form
Pull request #185 (2015-10-29 06:58:01)

Fix checkbox issue #175


Patch:
diff --git a/src/readFields.js b/src/readFields.js
index 71f94fb0..19076d94 100644
--- a/src/readFields.js
+++ b/src/readFields.js
@@ -48,6 +48,7 @@ const readFields = (props, myFields, asyncValidate, isReactNative) => {
       const formField = form[name] || {};
       if (field.value !== formField.value) {
         diff.value = formField.value;
+        diff.checked = typeof formField.value === 'boolean' ? formField.value : undefined;
       }
 
       // update dirty/pristine


Test patch:
diff --git a/src/__tests__/readFields.spec.js b/src/__tests__/readFields.spec.js
index 47d7e0dc..c1e1fcda 100644
--- a/src/__tests__/readFields.spec.js
+++ b/src/__tests__/readFields.spec.js
@@ -13,7 +13,7 @@ describe('readFields', () => {
   const focus = createRestorableSpy();
   const noValidation = () => ({});
 
-  const expectField = ({field, name, value, dirty, touched, visited, error, initialValue, readonly}) => {
+  const expectField = ({field, name, value, dirty, touched, visited, error, initialValue, readonly, checked}) => {
     expect(field)
       .toExist()
       .toBeA('object');
@@ -66,6 +66,7 @@ describe('readFields', () => {
     expect(field.pristine).toBe(!dirty);
     expect(field.touched).toBe(touched);
     expect(field.visited).toBe(visited);
+    expect(field.checked).toBe(checked);
 
     blur.restore();
     change.restore();
@@ -313,6 +314,66 @@ describe('readFields', () => {
     expect(result._meta.errors).toEqual({});
   });
 
+  it('should set checked for checkbox', () => {
+    const props = {
+      asyncBlurFields: [],
+      blur,
+      change,
+      fields: ['foo', 'bar'],
+      focus,
+      form: {
+        foo: {
+          value: false
+        },
+        bar: {
+          value: true
+        }
+      },
+      validate: noValidation
+    };
+    const previous = readFields(props, {});
+    const result = readFields({
+      ...props,
+      form: {
+        foo: {
+          value: true
+        },
+        bar: {
+          value: true
+        }
+      },
+      validate: noValidation
+    }, previous);
+    expectField({
+      field: result.foo,
+      name: 'foo',
+      value: true,
+      dirty: true,
+      touched: false,
+      visited: false,
+      error: undefined,
+      initialValue: undefined,
+      readonly: false,
+      checked: true
+    });
+    expectField({
+      field: result.bar,
+      name: 'bar',
+      value: true,
+      dirty: true,
+      touched: false,
+      visited: false,
+      error: undefined,
+      initialValue: undefined,
+      readonly: false,
+      checked: true
+    });
+    expect(result._meta.allPristine).toBe(false);
+    expect(result._meta.allValid).toBe(true);
+    expect(result._meta.values).toEqual({foo: true, bar: true});
+    expect(result._meta.errors).toEqual({});
+  });
+
   it('should initialize new fields', () => {
     const props = {
       asyncBlurFields: [],
Repository: erikras/redux-form
Pull request #225 (2015-11-04 23:44:20)

adding support to <select multiple>


Patch:
diff --git a/package.json b/package.json
index c4638f16..fa2c02bc 100644
--- a/package.json
+++ b/package.json
@@ -15,7 +15,7 @@
     "clean": "rimraf dist lib",
     "lint": "eslint src",
     "prepublish": "npm run lint && npm run test && npm run clean && npm run build",
-    "test": "mocha --compilers js:babel/register --recursive 'src/**/__tests__/*' --require src/__tests__/setup.js"
+    "test": "mocha --compilers js:babel/register --recursive src/**/__tests__/* --require src/__tests__/setup.js"
   },
   "keywords": [
     "react",
diff --git a/src/events/getValue.js b/src/events/getValue.js
index afd4deb8..33dea906 100644
--- a/src/events/getValue.js
+++ b/src/events/getValue.js
@@ -15,6 +15,16 @@ const getValue = (event, isReactNative) => {
     if (type === 'file') {
       return files || dataTransfer && dataTransfer.files;
     }
+    if(type === 'select-multiple') {
+      var options = event.target.options;
+      var values = [];
+      for (var i = 0, l = options.length; i < l; i++) {
+        if (options[i].selected) {
+          values.push(options[i].value);
+        }
+      }
+      return values;
+    }
     return value;
   }
   // not an event, so must be either our value or an object containing our value in the 'value' key


Test patch:
diff --git a/src/events/__tests__/getValue.spec.js b/src/events/__tests__/getValue.spec.js
index 77baa25b..2c8cec38 100644
--- a/src/events/__tests__/getValue.spec.js
+++ b/src/events/__tests__/getValue.spec.js
@@ -141,7 +141,30 @@ describe('getValue', () => {
       }
     }, false)).toBe(myFiles);
   });
-
+  it('should return selected options if is a multiselect', () => {
+    const options = [
+      {selected: true, value: 'foo'},
+      {selected: true, value: 'bar'},
+      {selected: false, value: 'baz'},
+    ];
+    const expected = options.filter(o => o.selected).map(o => o.value);
+    expect(getValue({
+      preventDefault: () => null,
+      stopPropagation: () => null,
+      target: {
+        type: 'select-multiple',
+        options
+      },
+    }, true)).toEqual(expected);
+    expect(getValue({
+      preventDefault: () => null,
+      stopPropagation: () => null,
+      target: {
+        type: 'select-multiple',
+        options
+      },
+    }, true)).toEqual(expected);
+  });
   it('should return event.target.value if not file or checkbox', () => {
     expect(getValue({
       preventDefault: () => null,
Repository: erikras/redux-form
Pull request #452 (2015-12-21 18:44:34)

Adds check for null state within setErrors
Previously was throwing error "TypeError: Cannot convert undefined or null to object"

This was being encountered in relation to async form submission [as seen in the submit-validation demo](http://erikras.github.io/redux-form/#/examples/submit-validation?_k=5igft0)

Credit: Implemented fix suggested by @box-turtle here https://github.com/erikras/redux-form/issues/446#issuecomment-166014354


Patch:
diff --git a/src/setErrors.js b/src/setErrors.js
index 86da6b81..b1377ccc 100644
--- a/src/setErrors.js
+++ b/src/setErrors.js
@@ -8,7 +8,7 @@ const setErrors = (state, errors, destKey) => {
     if (Array.isArray(state)) {
       return state.map((stateItem, index) => setErrors(stateItem, errors && errors[index], destKey));
     }
-    if (typeof state === 'object') {
+    if (state && typeof state === 'object') {
       return Object.keys(state)
         .reduce((accumulator, key) =>
             isMetaKey(key) ? accumulator : {


Test patch:
diff --git a/src/__tests__/setErrors.spec.js b/src/__tests__/setErrors.spec.js
index df2ae4c2..8a467a24 100644
--- a/src/__tests__/setErrors.spec.js
+++ b/src/__tests__/setErrors.spec.js
@@ -7,7 +7,7 @@ describe('setErrors', () => {
       .toEqual({foo: 42, bar: true});
   });
 
-  it('should set errors even when no state', () => {
+  it('should set errors even when state is empty', () => {
     expect(setErrors({}, {
       foo: 'fooError',
       bar: 'barError'
@@ -22,6 +22,17 @@ describe('setErrors', () => {
       });
   });
 
+  it('should set errors even when state is null', () => {
+    expect(setErrors(null, {
+      foo: 'fooError',
+    }, '__err'))
+      .toEqual({
+        foo: {
+          __err: 'fooError'
+        },
+      });
+  });
+
   it('should ignore meta keys', () => {
     expect(setErrors({}, {
       _startsWithUnderscore: 'shouldBeIgnored'
Repository: erikras/redux-form
Pull request #560 (2016-01-16 20:06:46)

Allow initial value to change to falsey value
Fixes: https://github.com/erikras/redux-form/issues/559

This allows `initialValue` and `defaultValue` to be changed to falsey values, but prevents updates when there is no `initial` key on the field


Patch:
diff --git a/src/updateField.js b/src/updateField.js
index 63664472..260744d2 100644
--- a/src/updateField.js
+++ b/src/updateField.js
@@ -43,7 +43,7 @@ const updateField = (field, formField, active, syncError) => {
     diff.visited = visited;
   }
 
-  if (formField.initial && formField.initial !== field.initialValue) {
+  if ('initial' in formField && formField.initial !== field.initialValue) {
     field.defaultChecked = formField.initial === true;
     field.defaultValue = formField.initial;
     field.initialValue = formField.initial;


Test patch:
diff --git a/src/__tests__/updateField.spec.js b/src/__tests__/updateField.spec.js
index 1a3b029d..7eb57075 100644
--- a/src/__tests__/updateField.spec.js
+++ b/src/__tests__/updateField.spec.js
@@ -116,4 +116,11 @@ describe('updateField', () => {
     expect(updateField({visited: true}, {visited: false}, false, undefined).visited).toBe(false);
     expect(updateField({visited: true}, {}, false, undefined).visited).toBe(false);
   });
+
+  it('should change initial and default values when initial changes', () => {
+    expect(updateField({ initialValue: 1, defaultValue: 1 }, { initial: 2 }, false, undefined).initialValue).toBe(2);
+    expect(updateField({ initialValue: 1, defaultValue: 1 }, { initial: 2 }, false, undefined).defaultValue).toBe(2);
+    expect(updateField({ initialValue: 1, defaultValue: 1 }, { initial: undefined }, false, undefined).initialValue).toBe(undefined);
+    expect(updateField({ initialValue: 1, defaultValue: 1 }, { initial: undefined }, false, undefined).defaultValue).toBe(undefined);
+  });
 });
Repository: erikras/redux-form
Pull request #618 (2016-02-04 03:25:45)

Return promise when callback function is passed to handleSubmit
fix for #580 
I hope there is no problem how it should be!

I'm not very sure if other Promise.reject in handleSubmit.js should return rejected promise with the validation errors. 
To be more specific,  here. https://github.com/haradakunihiko/redux-form/blob/master/src/handleSubmit.js#L30


Patch:
diff --git a/src/createHigherOrderComponent.js b/src/createHigherOrderComponent.js
index 9d141fa0..2e51b4e8 100644
--- a/src/createHigherOrderComponent.js
+++ b/src/createHigherOrderComponent.js
@@ -90,7 +90,7 @@ const createHigherOrderComponent = (config,
           // submitOrEvent is the submit function: return deferred submit thunk
           silenceEvents(event => {
             silenceEvent(event);
-            handleSubmit(check(submitOrEvent), getValues(fields, form), this.props, this.asyncValidate);
+            return handleSubmit(check(submitOrEvent), getValues(fields, form), this.props, this.asyncValidate);
           });
       }
 
diff --git a/src/handleSubmit.js b/src/handleSubmit.js
index 69945327..4a4d95e5 100644
--- a/src/handleSubmit.js
+++ b/src/handleSubmit.js
@@ -34,7 +34,7 @@ const handleSubmit = (submit, values, props, asyncValidate) => {
   submitFailed();
 
   if (returnRejectedSubmitPromise) {
-    return Promise.reject();
+    return Promise.reject(syncErrors);
   }
 };
 


Test patch:
diff --git a/src/__tests__/handleSubmit.spec.js b/src/__tests__/handleSubmit.spec.js
index 18e3f774..dd418d4d 100644
--- a/src/__tests__/handleSubmit.spec.js
+++ b/src/__tests__/handleSubmit.spec.js
@@ -34,13 +34,14 @@ describe('handleSubmit', () => {
   it('should stop and return rejected promise if sync validation fails and returnRejectedSubmitPromise', (done) => {
     const values = {foo: 'bar', baz: 42};
     const fields = ['foo', 'baz'];
+    const errorValue = {foo: 'error'};
     const submit = createSpy().andReturn(69);
     const touch = createSpy();
     const startSubmit = createSpy();
     const stopSubmit = createSpy();
     const submitFailed = createSpy();
     const asyncValidate = createSpy();
-    const validate = createSpy().andReturn({foo: 'error'});
+    const validate = createSpy().andReturn(errorValue);
     const props = {fields, startSubmit, stopSubmit, submitFailed, touch, validate, returnRejectedSubmitPromise: true};
 
     const result = handleSubmit(submit, values, props, asyncValidate);
@@ -59,7 +60,10 @@ describe('handleSubmit', () => {
     expect(submitFailed).toHaveBeenCalled();
     result.then(() => {
       expect(false).toBe(true); // should not be in resolve branch
-    }, done);
+    }, (error) => {
+      expect(error).toBe(errorValue);
+      done();
+    });
   });
 
   it('should return result of sync submit', () => {
Repository: erikras/redux-form
Pull request #643 (2016-02-12 17:15:28)

cloned field array on change
The field arrays were being mutated. They should be cloned whenever a field is added or removed.


Patch:
diff --git a/src/readField.js b/src/readField.js
index 2aba7ee6..9c7dcccb 100644
--- a/src/readField.js
+++ b/src/readField.js
@@ -39,8 +39,8 @@ const readField = (state, fieldName, pathToHere = '', fields, syncErrors, asyncV
         return accumulator;
       }, [])
       .map(field => getSuffix(field, prefix.length + closeIndex));
-    if (!fields[key]) {
-      fields[key] = [];
+    if (!fields[key] || fields[key].length !== stateArray.length) {
+      fields[key] = fields[key] ? [...fields[key]] : [];
       Object.defineProperty(fields[key], 'addField', {
         value: (value, index) => addArrayValue(pathToHere + key, value, index, subfields)
       });


Test patch:
diff --git a/src/__tests__/createReduxForm.spec.js b/src/__tests__/createReduxForm.spec.js
index b2bbe492..412fd04e 100644
--- a/src/__tests__/createReduxForm.spec.js
+++ b/src/__tests__/createReduxForm.spec.js
@@ -1304,6 +1304,8 @@ describe('createReduxForm', () => {
     expect(stub.props.fields.users.length).toBe(0);
     expect(stub.props.fields.users.addField).toBeA('function');
 
+    const before = stub.props.fields.users;
+
     // add field
     stub.props.fields.users.addField({name: 'Bob', age: 27});
 
@@ -1332,6 +1334,8 @@ describe('createReduxForm', () => {
       touched: false,
       visited: false
     });
+    const after = stub.props.fields.users;
+    expect(after).toNotBe(before);  // should be a new instance
 
     // check state
     expect(store.getState().form.testForm.users).toBeA('array');