nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: Yoctol/bottender
Pull request #193 (2018-02-14 17:22:40)

fix error  when verifying facebook signature
Fix call `.split` on a non-string value and also

`TypeError: First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.`


Patch:
diff --git a/examples/messenger-handover/index.js b/examples/messenger-handover/index.js
index 8c36552b..de1305ee 100644
--- a/examples/messenger-handover/index.js
+++ b/examples/messenger-handover/index.js
@@ -13,12 +13,15 @@ bot.onEvent(async context => {
   if (context.event.isText && !context.event.isEcho) {
     if (context.event.isStandby) {
       if (context.event.text === '/back') {
-        await context.takeThreadControl();
+        await context.client.takeThreadControl(context.session.user.id);
         await context.sendText('Taking thread control back.');
       }
     } else if (context.event.text === '/help') {
       await context.sendText('Passing thread control to the page inbox.');
-      await context.passThreadControlToPageInbox();
+      await context.client.passThreadControl(
+        context.session.user.id,
+        263902037430900 // target_app_id of Page Inbox
+      );
     } else {
       await context.sendText('Respond by bot.');
     }
diff --git a/src/bot/MessengerConnector.js b/src/bot/MessengerConnector.js
index 54905509..ca01c655 100644
--- a/src/bot/MessengerConnector.js
+++ b/src/bot/MessengerConnector.js
@@ -289,7 +289,13 @@ export default class MessengerConnector
       return true;
     }
 
-    const bufferFromSignature = Buffer.from(signature.split('sha1=')[1], 'hex');
+    if (typeof signature !== 'string') return false;
+
+    const sha1 = signature.split('sha1=')[1];
+
+    if (!sha1) return false;
+
+    const bufferFromSignature = Buffer.from(sha1, 'hex');
 
     const hashBufferFromBody = crypto
       .createHmac('sha1', this._appSecret)


Test patch:
diff --git a/src/bot/__tests__/MessengerConnector.spec.js b/src/bot/__tests__/MessengerConnector.spec.js
index 02b47a09..e4217641 100644
--- a/src/bot/__tests__/MessengerConnector.spec.js
+++ b/src/bot/__tests__/MessengerConnector.spec.js
@@ -543,4 +543,20 @@ describe('#verifySignature', () => {
 
     expect(result).toBe(true);
   });
+
+  it('should return false if signature is undefined', () => {
+    const { connector } = setup();
+
+    const result = connector.verifySignature('rawBody', undefined);
+
+    expect(result).toBe(false);
+  });
+
+  it('should return false if signature dont have a sha1= prefix', () => {
+    const { connector } = setup();
+
+    const result = connector.verifySignature('rawBody', 'sha256!!!');
+
+    expect(result).toBe(false);
+  });
 });
Repository: Yoctol/bottender
Pull request #235 (2018-04-12 08:26:42)

deepClone when read from MemoryCacheStore (merge into master)
also merge into master


Patch:
diff --git a/src/cache/MemoryCacheStore.js b/src/cache/MemoryCacheStore.js
index 62fc8890..be6d1976 100644
--- a/src/cache/MemoryCacheStore.js
+++ b/src/cache/MemoryCacheStore.js
@@ -13,7 +13,12 @@ export default class MemoryCacheStore implements CacheStore {
   }
 
   async get(key: string): Promise<mixed> {
-    const value = await this._lru.get(key);
+    const _value = this._lru.get(key);
+
+    // cloneDeep: To make sure read as different object to prevent
+    // reading same key multiple times, causing freezed by other events.
+    const value = typeof _value === 'object' ? cloneDeep(_value) : _value;
+
     return value || null;
   }
 


Test patch:
diff --git a/src/cache/__tests__/MemoryCacheStore.spec.js b/src/cache/__tests__/MemoryCacheStore.spec.js
index ecfa5271..cd6c19c1 100644
--- a/src/cache/__tests__/MemoryCacheStore.spec.js
+++ b/src/cache/__tests__/MemoryCacheStore.spec.js
@@ -8,6 +8,18 @@ describe('#get', () => {
     expect(await store.get('x')).toBe('abc');
   });
 
+  it('should get different object when get multiple times', async () => {
+    const store = new MemoryCacheStore(5);
+
+    await store.put('x', { a: 1 }, 5);
+
+    const result1 = await store.get('x');
+    const result2 = await store.get('x');
+
+    expect(result1).not.toBe(result2);
+    expect(result1).toEqual(result2);
+  });
+
   it('should get null when value does not exist', async () => {
     const store = new MemoryCacheStore(5);
Repository: Yoctol/bottender
Pull request #250 (2018-04-24 13:16:00)

export Context from entry
For custom connectors:

https://github.com/bottenderjs/bottenderjs.github.io/pull/56


Patch:
diff --git a/src/browser.js b/src/browser.js
index 55a24fc6..6e2ebebf 100644
--- a/src/browser.js
+++ b/src/browser.js
@@ -26,5 +26,8 @@ export { default as MemorySessionStore } from './session/MemorySessionStore';
 /* HandlerBuilder */
 export { default as ClassifierHandler } from './handlers/ClassifierHandler';
 
+/* Context */
+export { default as Context } from './context/Context';
+
 /* Plugins */
 export { default as withTyping } from './plugins/withTyping';
diff --git a/src/index.js b/src/index.js
index ee5282cc..f6acef38 100644
--- a/src/index.js
+++ b/src/index.js
@@ -53,6 +53,7 @@ export { default as ClassifierHandler } from './handlers/ClassifierHandler';
 export { default as withTyping } from './plugins/withTyping';
 
 /* Context */
+export { default as Context } from './context/Context';
 export { default as ConsoleContext } from './context/ConsoleContext';
 export { default as MessengerContext } from './context/MessengerContext';
 export { default as LineContext } from './context/LineContext';


Test patch:
diff --git a/src/__tests__/browser.spec.js b/src/__tests__/browser.spec.js
index 78bd2e25..75b32a77 100644
--- a/src/__tests__/browser.spec.js
+++ b/src/__tests__/browser.spec.js
@@ -24,6 +24,10 @@ describe('browser', () => {
     expect(core.ClassifierHandler).toBeDefined();
   });
 
+  it('export contexts', () => {
+    expect(core.Context).toBeDefined();
+  });
+
   it('export extensions', () => {
     expect(core.withTyping).toBeDefined();
   });
diff --git a/src/__tests__/index.spec.js b/src/__tests__/index.spec.js
index 5088f5c3..16f59867 100644
--- a/src/__tests__/index.spec.js
+++ b/src/__tests__/index.spec.js
@@ -45,6 +45,10 @@ describe('core', () => {
     expect(core.ClassifierHandler).toBeDefined();
   });
 
+  it('export contexts', () => {
+    expect(core.Context).toBeDefined();
+  });
+
   it('export extensions', () => {
     expect(core.withTyping).toBeDefined();
   });
Repository: Yoctol/bottender
Pull request #275 (2018-06-01 07:34:10)

fix console falsy getters
fix irrelevant warning when using `ConsoleBot` with `context.setState` and `context.resetState`


Patch:
diff --git a/src/context/ConsoleContext.js b/src/context/ConsoleContext.js
index 368d4762..59543cbe 100644
--- a/src/context/ConsoleContext.js
+++ b/src/context/ConsoleContext.js
@@ -38,7 +38,7 @@ export default class ConsoleContext extends Context implements PlatformContext {
       // $FlowExpectedError
       return new Proxy(this, {
         get(target, key) {
-          if (target[key]) {
+          if (target[key] !== undefined) {
             return target[key];
           }
 


Test patch:
diff --git a/src/context/__tests__/ConsoleContext.spec.js b/src/context/__tests__/ConsoleContext.spec.js
index 64b8eba1..e644aaed 100644
--- a/src/context/__tests__/ConsoleContext.spec.js
+++ b/src/context/__tests__/ConsoleContext.spec.js
@@ -112,6 +112,12 @@ describe('method missing', () => {
     expect(context.handlerDidEnd).toBeUndefined();
     expect(context.then).toBeUndefined();
   });
+
+  it('should not proxy falsy getters', async () => {
+    const { context } = setup({ fallbackMethods: true });
+
+    expect(context.isSessionWritten).toBe(false);
+  });
 });
 
 describe('#typing', () => {
Repository: Yoctol/bottender
Pull request #324 (2018-08-20 07:57:46)

add config to override consoleBot platform
add config to override platform in console bot mode, which makes it easier to check through the bot while doing multi-platform developing.


Patch:
diff --git a/src/bot/ConsoleBot.js b/src/bot/ConsoleBot.js
index 0b2eba9b..06b1e217 100644
--- a/src/bot/ConsoleBot.js
+++ b/src/bot/ConsoleBot.js
@@ -10,8 +10,13 @@ export default class ConsoleBot extends Bot {
   constructor({
     sessionStore,
     fallbackMethods,
-  }: { sessionStore: SessionStore, fallbackMethods?: boolean } = {}) {
-    const connector = new ConsoleConnector({ fallbackMethods });
+    mockPlatform,
+  }: {
+    sessionStore: SessionStore,
+    fallbackMethods?: boolean,
+    mockPlatform?: string,
+  } = {}) {
+    const connector = new ConsoleConnector({ fallbackMethods, mockPlatform });
     super({ connector, sessionStore, sync: true });
   }
 
diff --git a/src/bot/ConsoleConnector.js b/src/bot/ConsoleConnector.js
index de43d36d..b9bff51e 100644
--- a/src/bot/ConsoleConnector.js
+++ b/src/bot/ConsoleConnector.js
@@ -12,6 +12,7 @@ type ConsoleRequestBody = ConsoleRawEvent;
 type ConstructorOptions = {|
   client?: ConsoleClient,
   fallbackMethods?: boolean,
+  mockPlatform?: string,
 |};
 
 export default class ConsoleConnector implements Connector<ConsoleRequestBody> {
@@ -19,17 +20,24 @@ export default class ConsoleConnector implements Connector<ConsoleRequestBody> {
 
   _fallbackMethods: boolean;
 
-  constructor({ client, fallbackMethods }: ConstructorOptions = {}) {
+  _platform: string;
+
+  constructor({
+    client,
+    fallbackMethods,
+    mockPlatform,
+  }: ConstructorOptions = {}) {
     this._client = client || {
       sendText: text => {
         process.stdout.write(`Bot > ${text}\n`);
       },
     };
     this._fallbackMethods = fallbackMethods || false;
+    this._platform = mockPlatform || 'console';
   }
 
   get platform(): string {
-    return 'console';
+    return this._platform;
   }
 
   get client(): ConsoleClient {


Test patch:
diff --git a/src/bot/__tests__/ConsoleConnector.spec.js b/src/bot/__tests__/ConsoleConnector.spec.js
index 6006e46e..3179f8d5 100644
--- a/src/bot/__tests__/ConsoleConnector.spec.js
+++ b/src/bot/__tests__/ConsoleConnector.spec.js
@@ -8,17 +8,24 @@ const request = {
   },
 };
 
-function setup() {
+function setup(option) {
   return {
-    connector: new ConsoleConnector(),
+    connector: new ConsoleConnector(option),
   };
 }
 
 describe('#platform', () => {
-  it('should be console', () => {
+  it('should be console, when no extra option set', () => {
     const { connector } = setup();
     expect(connector.platform).toBe('console');
   });
+
+  it('should be overide by mockPlatform setting', () => {
+    const { connector } = setup({
+      mockPlatform: 'messenger',
+    });
+    expect(connector.platform).toBe('messenger');
+  });
 });
 
 describe('#client', () => {
Repository: paustint/soql-parser-js
Pull request #132 (2021-01-08 03:10:55)

getFlattenedFields does not correctly handle alias
... for grouped expressions

Added check to return alias instead of related field for aggregate exp

resolves #31


Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index db8adf0..5b1deb7 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,11 @@
 # Changelog
 
+## 3.0.1
+
+January 7, 20201
+
+1. `getFlattenedFields` did not properly handle the alias for an aggregate function within an aggregate query. (#131)
+
 ## 3.0.0
 
 October 14, 2020
diff --git a/src/api/public-utils.ts b/src/api/public-utils.ts
index b986bae..c9e1691 100644
--- a/src/api/public-utils.ts
+++ b/src/api/public-utils.ts
@@ -192,6 +192,10 @@ export function getFlattenedFields(
             return param;
           });
 
+          if (field.alias && (field.isAggregateFn || isAggregateResult)) {
+            return field.alias;
+          }
+
           if (field.alias) {
             const firstParam = params[0];
             // Include the full path and replace the field with the alias


Test patch:
diff --git a/test/public-utils-test-data.ts b/test/public-utils-test-data.ts
index c6dc753..548332a 100644
--- a/test/public-utils-test-data.ts
+++ b/test/public-utils-test-data.ts
@@ -414,4 +414,32 @@ export const testCases: FlattenedObjTestCase[] = [
       },
     },
   },
+  {
+    testCase: 13,
+    expectedFields: ['AccountId', 'AcctCreatedDate'],
+    query: {
+      fields: [
+        {
+          type: 'Field',
+          field: 'AccountId',
+        },
+        {
+          type: 'FieldFunctionExpression',
+          functionName: 'MAX',
+          parameters: ['Account.CreatedDate'],
+          isAggregateFn: true,
+          rawValue: 'MAX(Account.CreatedDate)',
+          alias: 'AcctCreatedDate',
+        },
+      ],
+      sObject: 'Contact',
+      groupBy: {
+        field: ['AccountId'],
+      },
+    },
+    sfdcObj: {
+      AccountId: '0016g00000ETu0HAAT',
+      AcctCreatedDate: '2020-02-28T03:00:31.000+0000',
+    },
+  },
 ];
Repository: paularmstrong/build-tracker
Pull request #111 (2020-02-14 15:09:04)

Fix config error
<!--
Thank you so much for contributing to open source and the Build Tracker project!
-->

# Problem

Currently, if the config file errors, the CLI will return a generic error message: "Could not find configuration file". However this is misleading, because the config _was_ found.

With this PR, we only use this error message when the config file was genuinely not found. Otherwise we use the error that came from the config file.

# Solution

<!--
When trying to solve more solutions with Build Tracker, please keep in mind some of the following goals of the project:
* Be lightweight: small package sizes (single-digit KiBs, gzipped)
* Be easy: too many options in an API can become confusing
* Be clear: the intended purpose of every method should be as obvious as possible
* Is it easy to do this in "userland"? Would it be better off done there?
-->

Explain your approach. Sometimes it helps to justify your approach against some others that you didn't choose to explain why yours is better.

# TODO

- [x] 🤓 Add & update tests (always try to _increase_ test coverage)
- [x] 🔬 Ensure CI is passing (`yarn lint:ci`, `yarn test`, `yarn tsc:ci`)
- [x] 📖 Update relevant documentation



Patch:
diff --git a/src/cli/src/modules/config.ts b/src/cli/src/modules/config.ts
index 247d807..c8785ff 100644
--- a/src/cli/src/modules/config.ts
+++ b/src/cli/src/modules/config.ts
@@ -35,7 +35,11 @@ export default async function getConfig(path?: string): Promise<Config> {
   try {
     result = !path ? await explorer.search() : await explorer.load(path);
   } catch (e) {
-    throw new Error('Could not find configuration file');
+    if (e.code === 'ENOENT') {
+      throw new Error('Could not find configuration file');
+    } else {
+      throw e;
+    }
   }
 
   return {
diff --git a/src/fixtures/cli-configs/rc/.build-trackerrc-invalid.js b/src/fixtures/cli-configs/rc/.build-trackerrc-invalid.js
new file mode 100644
index 0000000..478d9ec
--- /dev/null
+++ b/src/fixtures/cli-configs/rc/.build-trackerrc-invalid.js
@@ -0,0 +1,1 @@
+throw new Error('test');
\ No newline at end of file


Test patch:
diff --git a/src/cli/src/modules/__tests__/config.test.ts b/src/cli/src/modules/__tests__/config.test.ts
index 95d3e36..42165fb 100644
--- a/src/cli/src/modules/__tests__/config.test.ts
+++ b/src/cli/src/modules/__tests__/config.test.ts
@@ -31,6 +31,14 @@ describe('getConfig', () => {
     });
   });
 
+  test('propagate errors', () => {
+    return getConfig(
+      path.join(path.dirname(require.resolve('@build-tracker/fixtures')), 'cli-configs/rc/.build-trackerrc-invalid.js')
+    ).catch(e => {
+      expect(e.message).toMatch('test');
+    });
+  });
+
   test('throws if no configuration found', () => {
     return getConfig('tacos').catch(e => {
       expect(e.message).toMatch('Could not find configuration file');
Repository: paularmstrong/build-tracker
Pull request #139 (2020-02-20 17:33:04)

Handle merge commits
Fixes https://github.com/paularmstrong/build-tracker/issues/137

<!--
Thank you so much for contributing to open source and the Build Tracker project!
-->

# Problem

Explain the problem that this pull request aims to resolve.

# Solution

<!--
When trying to solve more solutions with Build Tracker, please keep in mind some of the following goals of the project:
* Be lightweight: small package sizes (single-digit KiBs, gzipped)
* Be easy: too many options in an API can become confusing
* Be clear: the intended purpose of every method should be as obvious as possible
* Is it easy to do this in "userland"? Would it be better off done there?
-->

Explain your approach. Sometimes it helps to justify your approach against some others that you didn't choose to explain why yours is better.

# TODO

- [x] 🤓 Add & update tests (always try to _increase_ test coverage)
- [x] 🔬 Ensure CI is passing (`yarn lint:ci`, `yarn test`, `yarn tsc:ci`)
- [x] 📖 Update relevant documentation



Patch:
diff --git a/src/cli/src/modules/git.ts b/src/cli/src/modules/git.ts
index 4f67f8a..0f281e3 100644
--- a/src/cli/src/modules/git.ts
+++ b/src/cli/src/modules/git.ts
@@ -39,7 +39,10 @@ export function getMergeBase(branch: string, cwd: string = process.cwd()): Promi
 export function getParentRevision(sha: string, cwd: string = process.cwd()): Promise<string> {
   return spawn('git', ['log', '--pretty=%P', '-n', '1', sha], { cwd }).then(
     (buffer: Buffer): string => {
-      return buffer.toString().trim();
+      return buffer
+        .toString()
+        .trim()
+        .split(' ')[0];
     }
   );
 }


Test patch:
diff --git a/src/cli/src/modules/__tests__/git.test.ts b/src/cli/src/modules/__tests__/git.test.ts
index 1133ba7..dd98e72 100644
--- a/src/cli/src/modules/__tests__/git.test.ts
+++ b/src/cli/src/modules/__tests__/git.test.ts
@@ -139,6 +139,17 @@ describe('git', () => {
       });
     });
 
+    test('returns the parent sha for the given sha (merge commit)', () => {
+      const spawn = jest
+        .spyOn(Spawn, 'default')
+        .mockImplementation(() => Promise.resolve(Buffer.from('123556 abcdef')));
+
+      return Git.getParentRevision('tacos').then(branch => {
+        expect(spawn).toHaveBeenCalledWith('git', ['log', '--pretty=%P', '-n', '1', 'tacos'], expect.any(Object));
+        expect(branch).toBe('123556');
+      });
+    });
+
     test('uses the process cwd', () => {
       const spawn = jest.spyOn(Spawn, 'default').mockImplementation(() => Promise.resolve(Buffer.from('\n')));