nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: nicklaw5/helix
Pull request #97 (2021-06-12 10:15:38)

channelinfo: fix delay field type
first, thanks for making this project available! 

I was trying to use the Getchannelinfo and when made a request it failed
```
 Failed to decode API response: json: cannot unmarshal number into Go struct field ChannelInformation.data.delay of type string
 ```

checking the Twitch API https://dev.twitch.tv/docs/api/reference#get-channel-information the `delay` field is an Int and not string

this PR fixes that




Patch:
diff --git a/channels.go b/channels.go
index 9c373f5..9be5664 100644
--- a/channels.go
+++ b/channels.go
@@ -86,10 +86,10 @@ type ChannelInformation struct {
 	BroadcasterID       string `json:"broadcaster_id"`
 	BroadcasterName     string `json:"broadcaster_name"`
 	BroadcasterLanguage string `json:"broadcaster_language"`
-	Delay               string `json:"delay"`
 	GameID              string `json:"game_id"`
 	GameName            string `json:"game_name"`
 	Title               string `json:"title"`
+	Delay               int    `json:"delay"`
 }
 
 // GetChannelInformation ...


Test patch:
diff --git a/channels_test.go b/channels_test.go
index 8d8c01f..3ccaf9d 100644
--- a/channels_test.go
+++ b/channels_test.go
@@ -146,7 +146,7 @@ func TestGetChannelInformation(t *testing.T) {
 			http.StatusOK,
 			&Options{ClientID: "my-client-id"},
 			"44445592",
-			`{"data":[{"broadcaster_id":"44445592","broadcaster_login":"pokimane","broadcaster_name":"pokimane","broadcaster_language":"en","game_id":"509658","game_name":"Just Chatting","title":"See you Wednesday 8am for Among Us ^_^"}]}`,
+			`{"data":[{"broadcaster_id":"44445592","broadcaster_login":"pokimane","broadcaster_name":"pokimane","broadcaster_language":"en","game_id":"509658","game_name":"Just Chatting","title":"See you Wednesday 8am for Among Us ^_^", "delay": 2}]}`,
 			[]ChannelInformation{
 				{
 					BroadcasterID:       "44445592",
@@ -155,6 +155,7 @@ func TestGetChannelInformation(t *testing.T) {
 					GameID:              "509658",
 					GameName:            "Just Chatting",
 					Title:               "See you Wednesday 8am for Among Us ^_^",
+					Delay:               2,
 				},
 			},
 		},
Repository: nicklaw5/helix
Pull request #101 (2021-06-27 18:50:46)

Rename some struct fields
See diff for affected structs.

coveralls: ## Pull Request Test Coverage Report for [Build 976786483](https://coveralls.io/builds/40913466)

* **0** of **0**   changed or added relevant lines in **0** files are covered.
* No unchanged relevant lines lost coverage.
* Overall coverage remained the same at **96.345%**

---



|  Totals | [![Coverage Status](https://coveralls.io/builds/40913466/badge)](https://coveralls.io/builds/40913466) |
| :-- | --: |
| Change from base [Build 931730083](https://coveralls.io/builds/40535580): |  0.0% |
| Covered Lines: | 1028 |
| Relevant Lines: | 1067 |

---
##### 💛  - [Coveralls](https://coveralls.io)


Patch:
diff --git a/channels_points.go b/channels_points.go
index 0069913..2f17f1f 100644
--- a/channels_points.go
+++ b/channels_points.go
@@ -48,9 +48,9 @@ type ChannelCustomReward struct {
 
 // RewardImage ...
 type RewardImage struct {
-	Url1 string `json:"url_1x"`
-	Url2 string `json:"url_2x"`
-	Url4 string `json:"url_4x"`
+	Url1x string `json:"url_1x"`
+	Url2x string `json:"url_2x"`
+	Url4x string `json:"url_4x"`
 }
 
 // MaxPerUserPerStreamSettings ...
diff --git a/chat.go b/chat.go
index 7694020..6dae024 100644
--- a/chat.go
+++ b/chat.go
@@ -92,12 +92,12 @@ type ManyEmotesWithOwner struct {
 
 // Emote ...
 type Emote struct {
-	ID     string     `json:"id"`
-	Name   string     `json:"name"`
-	Images EmoteImage `json:"images"`
-	Tier   string     `json:"tier"`
-	Type   string     `json:"emote_type"`
-	Set_ID string     `json:"emote_set_id"`
+	ID         string     `json:"id"`
+	Name       string     `json:"name"`
+	Images     EmoteImage `json:"images"`
+	Tier       string     `json:"tier"`
+	EmoteType  string     `json:"emote_type"`
+	EmoteSetId string     `json:"emote_set_id"`
 }
 
 // EmoteWithOwner ...
diff --git a/eventsub.go b/eventsub.go
index 0203a6e..dac1ef9 100644
--- a/eventsub.go
+++ b/eventsub.go
@@ -457,9 +457,9 @@ type EventSubGlobalCooldown struct {
 
 // This also belongs to a custom reward and defines the image urls
 type EventSubImage struct {
-	Url1X string `json:"url_1x"`
-	Url2X string `json:"url_2x"`
-	Url4X string `json:"url_4x"`
+	Url1x string `json:"url_1x"`
+	Url2x string `json:"url_2x"`
+	Url4x string `json:"url_4x"`
 }
 
 // This belongs to a hype train and defines a user contribution


Test patch:
diff --git a/chat_test.go b/chat_test.go
index e138198..9af87ab 100644
--- a/chat_test.go
+++ b/chat_test.go
@@ -326,8 +326,8 @@ func TestGetEmoteSets(t *testing.T) {
 							Url2x: "https://static-cdn.jtvnw.net/emoticons/v1/301147694/2.0",
 							Url4x: "https://static-cdn.jtvnw.net/emoticons/v1/301147694/3.0",
 						},
-						Type:   "subscriptions",
-						Set_ID: "300678379",
+						EmoteType:  "subscriptions",
+						EmoteSetId: "300678379",
 					},
 					OwnerID: "44931651",
 				},
Repository: nicklaw5/helix
Pull request #111 (2021-07-26 16:10:48)

HOTIX: user subscriptions total field
- Apply the total field from the response object to the many subscriptions total field
- Extend unit test to detect that the total is now pulling through

coveralls: ## Pull Request Test Coverage Report for [Build 1068097965](https://coveralls.io/builds/41653369)

* **1** of **1**   **(100.0%)**  changed or added relevant line in **1** file are covered.
* No unchanged relevant lines lost coverage.
* Overall coverage increased (+**0.2%**) to **96.606%**

---



|  Totals | [![Coverage Status](https://coveralls.io/builds/41653369/badge)](https://coveralls.io/builds/41653369) |
| :-- | --: |
| Change from base [Build 1057421189](https://coveralls.io/builds/41585499): |  0.2% |
| Covered Lines: | 1053 |
| Relevant Lines: | 1090 |

---
##### 💛  - [Coveralls](https://coveralls.io)


Patch:
diff --git a/subscriptions.go b/subscriptions.go
index bed0e59..207cbb8 100644
--- a/subscriptions.go
+++ b/subscriptions.go
@@ -72,6 +72,7 @@ func (c *Client) GetSubscriptions(params *SubscriptionsParams) (*SubscriptionsRe
 	resp.HydrateResponseCommon(&subscriptions.ResponseCommon)
 	subscriptions.Data.Subscriptions = resp.Data.(*ManySubscriptions).Subscriptions
 	subscriptions.Data.Pagination = resp.Data.(*ManySubscriptions).Pagination
+	subscriptions.Data.Total = resp.Data.(*ManySubscriptions).Total
 
 	return subscriptions, nil
 }


Test patch:
diff --git a/subscriptions_test.go b/subscriptions_test.go
index 6c582cf..050f608 100644
--- a/subscriptions_test.go
+++ b/subscriptions_test.go
@@ -59,6 +59,11 @@ func TestGetSubscriptions(t *testing.T) {
 
 			continue
 		}
+
+		if resp.Data.Total != 1 {
+			t.Errorf("expected total field to be 1 got %d", resp.Data.Total)
+		}
+
 	}
 
 	// Test with HTTP Failure
Repository: nicklaw5/helix
Pull request #120 (2021-09-12 09:25:55)

Client method "CheckUserSubsription" -> "CheckUserSubscription"
Simple spelling mistake—you'll definitely want to merge this before you release v2, though =b


Patch:
diff --git a/docs/subscriptions_docs.md b/docs/subscriptions_docs.md
index 3237647..fa64932 100644
--- a/docs/subscriptions_docs.md
+++ b/docs/subscriptions_docs.md
@@ -36,7 +36,7 @@ if err != nil {
     // handle error
 }
 
-resp, err := client.CheckUserSubsription(&helix.UserSubscriptionsParams{
+resp, err := client.CheckUserSubscription(&helix.UserSubscriptionsParams{
     BroadcasterID: "29776980",
     UserID:        "145328278",
 })
@@ -45,4 +45,4 @@ if err != nil {
 }
 
 fmt.Printf("%+v\n", resp)
-```
+```
\ No newline at end of file
diff --git a/subscriptions.go b/subscriptions.go
index 207cbb8..987aa91 100644
--- a/subscriptions.go
+++ b/subscriptions.go
@@ -77,10 +77,10 @@ func (c *Client) GetSubscriptions(params *SubscriptionsParams) (*SubscriptionsRe
 	return subscriptions, nil
 }
 
-// CheckUserSubsription Check if a specific user is subscribed to a specific channel
+// CheckUserSubscription Check if a specific user is subscribed to a specific channel
 //
 // Required scope: user:read:subscriptions
-func (c *Client) CheckUserSubsription(params *UserSubscriptionsParams) (*UserSubscriptionResponse, error) {
+func (c *Client) CheckUserSubscription(params *UserSubscriptionsParams) (*UserSubscriptionResponse, error) {
 	resp, err := c.get("/subscriptions/user", &ManyUserSubscriptions{}, params)
 	if err != nil {
 		return nil, err


Test patch:
diff --git a/subscriptions_test.go b/subscriptions_test.go
index 050f608..2b18270 100644
--- a/subscriptions_test.go
+++ b/subscriptions_test.go
@@ -116,7 +116,7 @@ func TestChechUserSubscription(t *testing.T) {
 	for _, testCase := range testCases {
 		c := newMockClient(testCase.options, newMockHandler(testCase.statusCode, testCase.respBody, nil))
 
-		resp, err := c.CheckUserSubsription(&UserSubscriptionsParams{
+		resp, err := c.CheckUserSubscription(&UserSubscriptionsParams{
 			BroadcasterID: testCase.BroadcasterID,
 			UserID:        testCase.UserID,
 		})
@@ -154,7 +154,7 @@ func TestChechUserSubscription(t *testing.T) {
 		opts: options,
 	}
 
-	_, err := c.CheckUserSubsription(&UserSubscriptionsParams{})
+	_, err := c.CheckUserSubscription(&UserSubscriptionsParams{})
 	if err == nil {
 		t.Error("expected error but got nil")
 	}
Repository: nicklaw5/helix
Pull request #123 (2021-10-02 00:47:42)

feat(subscriptions): add new sub points field
2021‑10‑01: `Add the points field to the Get Broadcaster Subscriptions response. This field provides the current number of subscriber points earned by this broadcaster.` <https://dev.twitch.tv/docs/change-log>


Patch:
diff --git a/subscriptions.go b/subscriptions.go
index 987aa91..82528d7 100644
--- a/subscriptions.go
+++ b/subscriptions.go
@@ -29,6 +29,7 @@ type ManySubscriptions struct {
 	Subscriptions []Subscription `json:"data"`
 	Pagination    Pagination     `json:"pagination"`
 	Total         int            `json:"total"`
+	Points        int            `json:"points"` // Each Tier 1 is worth 1, Tier 2 is worth 2, and Tier 3 is worth 6
 }
 
 type ManyUserSubscriptions struct {
@@ -73,6 +74,7 @@ func (c *Client) GetSubscriptions(params *SubscriptionsParams) (*SubscriptionsRe
 	subscriptions.Data.Subscriptions = resp.Data.(*ManySubscriptions).Subscriptions
 	subscriptions.Data.Pagination = resp.Data.(*ManySubscriptions).Pagination
 	subscriptions.Data.Total = resp.Data.(*ManySubscriptions).Total
+	subscriptions.Data.Points = resp.Data.(*ManySubscriptions).Points
 
 	return subscriptions, nil
 }


Test patch:
diff --git a/subscriptions_test.go b/subscriptions_test.go
index 2b18270..53967b3 100644
--- a/subscriptions_test.go
+++ b/subscriptions_test.go
@@ -20,7 +20,7 @@ func TestGetSubscriptions(t *testing.T) {
 			&Options{ClientID: "my-client-id", UserAccessToken: "my-access-token"},
 			"123",
 			[]string{},
-			`{"data": [{"broadcaster_id":"123","broadcaster_login":"test_user","broadcaster_name":"test_user","is_gift":true,"gifter_id":"456","gifter_login":"another_user","gifter_name":"Another_User","tier":"3000","plan_name":"The Ninjas","user_id":"123","user_id":"123","user_login":"test_user","user_name":"test_user"}],"pagination":{"cursor":"xxxx"},"total":1}`,
+			`{"data": [{"broadcaster_id":"123","broadcaster_login":"test_user","broadcaster_name":"test_user","is_gift":true,"gifter_id":"456","gifter_login":"another_user","gifter_name":"Another_User","tier":"3000","plan_name":"The Ninjas","user_id":"123","user_id":"123","user_login":"test_user","user_name":"test_user"}],"pagination":{"cursor":"xxxx"},"total":1,"points":6}`,
 		},
 		{
 			http.StatusBadRequest,
@@ -64,6 +64,10 @@ func TestGetSubscriptions(t *testing.T) {
 			t.Errorf("expected total field to be 1 got %d", resp.Data.Total)
 		}
 
+		if resp.Data.Points != 6 {
+			t.Errorf("expected points field to be 6 got %d", resp.Data.Points)
+		}
+
 	}
 
 	// Test with HTTP Failure
Repository: nicklaw5/helix
Pull request #220 (2024-05-08 19:48:02)

Set users IDs as array to get ban users list


Patch:
diff --git a/moderation.go b/moderation.go
index c1cb95a..e69c1dd 100644
--- a/moderation.go
+++ b/moderation.go
@@ -23,9 +23,10 @@ type BannedUsersResponse struct {
 // BroadcasterID must match the auth tokens user_id
 type BannedUsersParams struct {
 	BroadcasterID string `query:"broadcaster_id"`
-	UserID        string `query:"user_id"`
-	After         string `query:"after"`
-	Before        string `query:"before"`
+	// Filter by provided UserIDs
+	UserID []string `query:"user_id"`
+	After  string   `query:"after"`
+	Before string   `query:"before"`
 }
 
 // GetBannedUsers returns all banned and timed-out users in a channel.


Test patch:
diff --git a/moderation_test.go b/moderation_test.go
index 3168f3b..91d2dbe 100644
--- a/moderation_test.go
+++ b/moderation_test.go
@@ -14,7 +14,7 @@ func TestGetBannedUsers(t *testing.T) {
 		statusCode    int
 		options       *Options
 		BroadcasterID string
-		UserID        string
+		UserID        []string
 		After         string
 		Before        string
 		respBody      string
@@ -23,7 +23,7 @@ func TestGetBannedUsers(t *testing.T) {
 			http.StatusBadRequest,
 			&Options{ClientID: "my-client-id"},
 			"", // missing broadcaster id
-			"",
+			[]string{},
 			"",
 			"",
 			`{"error":"Bad Request","status":400,"message":"Missing required parameter \"broadcaster_id\""}`,
@@ -32,7 +32,7 @@ func TestGetBannedUsers(t *testing.T) {
 			http.StatusOK,
 			&Options{ClientID: "my-client-id"},
 			"23161357",
-			"",
+			[]string{},
 			"",
 			"",
 			`{"data":[{"expires_at":"","user_id":"54946241","user_name":"chronophylos","user_name":"chronophylos"},{"expires_at":"2022-03-15T02:00:28Z","user_id":"423374343","user_name":"glowillig"}],"pagination":{"cursor":"eyJiIjpudWxsLCJhIjp7Ik9mZnNldCI6MX19"}}`,
Repository: terraform-docs/terraform-docs
Pull request #493 (2021-05-02 20:08:56)

Add missing Resource.Mode to plugin-sdk
### Description of your changes

fix for #492 bug. added missing field of the structure [Resource](https://github.com/terraform-docs/terraform-docs/blob/master/internal/terraform/resource.go#L22) the conversion method.

I have:

- [+] Read and followed terraform-docs' [contribution process].
- [+] All tests pass when I run `make test`.

### How has this code been tested

within the fix new test provided.

[contribution process]: https://git.io/JtEzg



Patch:
diff --git a/internal/terraform/resource.go b/internal/terraform/resource.go
index d057b84..4c2825a 100644
--- a/internal/terraform/resource.go
+++ b/internal/terraform/resource.go
@@ -91,6 +91,7 @@ func (rr resources) convert() []*terraformsdk.Resource {
 			Name:           r.Name,
 			ProviderName:   r.ProviderName,
 			ProviderSource: r.ProviderSource,
+			Mode:           r.Mode,
 			Version:        fmt.Sprintf("%v", r.Version.Raw()),
 			Position: terraformsdk.Position{
 				Filename: r.Position.Filename,


Test patch:
diff --git a/internal/terraform/resource_test.go b/internal/terraform/resource_test.go
index 835c586..2569c87 100644
--- a/internal/terraform/resource_test.go
+++ b/internal/terraform/resource_test.go
@@ -31,6 +31,24 @@ func TestResourceSpec(t *testing.T) {
 	}
 	assert.Equal("tls_private_key.baz", resource.Spec())
 }
+func TestPluginSdkConversion(t *testing.T) {
+	assert := assert.New(t)
+	resource := Resource{
+		Type:           "private_key",
+		Name:           "baz",
+		ProviderName:   "tls",
+		ProviderSource: "hashicorp/tls",
+		Mode:           "managed",
+		Version:        types.String("latest"),
+	}
+	sdkResource := resources{&resource}.convert()[0]
+	assert.Equal(resource.Type, sdkResource.Type)
+	assert.Equal(resource.Name, sdkResource.Name)
+	assert.Equal(resource.ProviderName, sdkResource.ProviderName)
+	assert.Equal(resource.ProviderSource, sdkResource.ProviderSource)
+	assert.Equal(resource.Mode, sdkResource.Mode)
+	assert.Equal(resource.Version, types.String(sdkResource.Version))
+}
 
 func TestResourceMode(t *testing.T) {
 	tests := map[string]struct {
Repository: Yoctol/bottender
Pull request #110 (2017-12-19 16:53:56)

support telegram context.sendMediaGroup
Added in [messaging-api-telegram v0.6.1](https://github.com/Yoctol/messaging-apis/releases/tag/v0.6.1)


Patch:
diff --git a/src/context/TelegramContext.js b/src/context/TelegramContext.js
index 81cb70ef..cd16b58e 100644
--- a/src/context/TelegramContext.js
+++ b/src/context/TelegramContext.js
@@ -72,6 +72,7 @@ const sendMethods = [
   'sendVideo',
   'sendVoice',
   'sendVideoNote',
+  'sendMediaGroup',
   'sendLocation',
   'sendVenue',
   'sendContact',


Test patch:
diff --git a/src/context/__tests__/TelegramContext.spec.js b/src/context/__tests__/TelegramContext.spec.js
index ca558dba..d996b57d 100644
--- a/src/context/__tests__/TelegramContext.spec.js
+++ b/src/context/__tests__/TelegramContext.spec.js
@@ -24,6 +24,8 @@ const createMockTelegramClient = () => ({
   sendSticker: jest.fn(),
   sendVideo: jest.fn(),
   sendVoice: jest.fn(),
+  sendVideoNote: jest.fn(),
+  sendMediaGroup: jest.fn(),
   sendLocation: jest.fn(),
   sendVenue: jest.fn(),
   sendContact: jest.fn(),
@@ -261,6 +263,48 @@ describe('#sendVoice', () => {
   });
 });
 
+describe('#sendVideoNote', () => {
+  it('should call client.sendVideoNote', async () => {
+    const { context, client, session } = setup();
+
+    await context.sendVideoNote('xxx.mp4');
+
+    expect(client.sendVideoNote).toBeCalledWith(session.user.id, 'xxx.mp4');
+  });
+
+  it('should mark context as handled', async () => {
+    const { context } = setup();
+
+    await context.sendVideoNote('xxx.mp4');
+
+    expect(context.isHandled).toBe(true);
+  });
+});
+
+describe('#sendMediaGroup', () => {
+  it('should call client.sendMediaGroup', async () => {
+    const { context, client, session } = setup();
+
+    await context.sendMediaGroup([
+      { type: 'photo', media: 'BQADBAADApYAAgcZZAfj2-xeidueWwI' },
+    ]);
+
+    expect(client.sendMediaGroup).toBeCalledWith(session.user.id, [
+      { type: 'photo', media: 'BQADBAADApYAAgcZZAfj2-xeidueWwI' },
+    ]);
+  });
+
+  it('should mark context as handled', async () => {
+    const { context } = setup();
+
+    await context.sendMediaGroup([
+      { type: 'photo', media: 'BQADBAADApYAAgcZZAfj2-xeidueWwI' },
+    ]);
+
+    expect(context.isHandled).toBe(true);
+  });
+});
+
 describe('#sendLocation', () => {
   it('#sendLocation to call client.sendLocation', async () => {
     const { context, client, session } = setup();
Repository: Yoctol/bottender
Pull request #142 (2018-01-06 06:40:36)

Handling error in express middleware
The express middleware actually doesn't handle the async error, i.e. a Promise rejection

The `createMiddleware` may throw error from the `requestHandler` which converts body to the context.

This PR improve the error catching, and forward to the next downstream to prevent `DEP0018: Unhandled promise rejections` warning


Patch:
diff --git a/src/express/createMiddleware.js b/src/express/createMiddleware.js
index fb03a651..dc7717a8 100644
--- a/src/express/createMiddleware.js
+++ b/src/express/createMiddleware.js
@@ -1,6 +1,9 @@
 function createMiddleware(bot) {
   const requestHandler = bot.createRequestHandler();
-  return async (req, res) => {
+
+  const wrapper = fn => (req, res, next) =>
+    fn(req, res).catch(err => next(err));
+  return wrapper(async (req, res) => {
     if (!req.body) {
       throw new Error(
         'createMiddleware(): Missing body parser. Use `body-parser` or other similar package before this middleware.'
@@ -15,7 +18,7 @@ function createMiddleware(bot) {
       res.status(200);
       res.send('');
     }
-  };
+  });
 }
 
 export default createMiddleware;


Test patch:
diff --git a/src/express/__tests__/createMiddleware.spec.js b/src/express/__tests__/createMiddleware.spec.js
index 1dabb7b6..f6030c81 100644
--- a/src/express/__tests__/createMiddleware.spec.js
+++ b/src/express/__tests__/createMiddleware.spec.js
@@ -22,11 +22,13 @@ it('should response 200 when no error be thrown', async () => {
     send: jest.fn(),
     status: jest.fn(),
   };
+  const next = jest.fn();
 
-  await middleware(req, res);
+  await middleware(req, res, next);
 
   expect(res.status).toBeCalledWith(200);
   expect(res.send).toBeCalledWith('');
+  expect(next).not.toBeCalled();
 });
 
 it('should response 200 if there is response return from requestHandler', async () => {
@@ -87,14 +89,34 @@ it('should throw when no body exists', async () => {
 
   const req = {};
   const res = {};
+  const next = jest.fn();
+
+  await middleware(req, res, next);
 
-  let error;
-  try {
-    await middleware(req, res);
-  } catch (err) {
-    error = err;
-  }
+  expect(next).toBeCalled();
+  const error = next.mock.calls[0][0];
 
   expect(error).toBeDefined();
   expect(error.message).toMatch(/Missing body parser/);
 });
+
+it('should catch error when requestHandler error', async () => {
+  const { bot, requestHandler } = setup();
+  requestHandler.mockReturnValue(
+    Promise.reject(new Error('requestHandler error'))
+  );
+
+  const middleware = createMiddleware(bot);
+
+  const req = { body: {} };
+  const res = {};
+  const next = jest.fn();
+
+  await middleware(req, res, next);
+
+  expect(next).toBeCalled();
+  const error = next.mock.calls[0][0];
+
+  expect(error).toBeDefined();
+  expect(error.message).toMatch(/requestHandler error/);
+});
Repository: Yoctol/bottender
Pull request #155 (2018-01-16 06:54:37)

better handle Messenger getUserProfile failure


Patch:
diff --git a/src/bot/MessengerConnector.js b/src/bot/MessengerConnector.js
index e212a316..54905509 100644
--- a/src/bot/MessengerConnector.js
+++ b/src/bot/MessengerConnector.js
@@ -206,9 +206,18 @@ export default class MessengerConnector
       }
 
       // FIXME: refine user
-      const user = await this._client.getUserProfile(senderId, {
-        access_token: customAccessToken,
-      });
+      let user = {};
+      try {
+        user = await this._client.getUserProfile(senderId, {
+          access_token: customAccessToken,
+        });
+      } catch (e) {
+        warning(
+          false,
+          'getUserProfile() failed, `session.user` will only have `id`'
+        );
+        console.error(e);
+      }
 
       session.user = {
         _updatedAt: new Date().toISOString(),


Test patch:
diff --git a/src/bot/__tests__/MessengerConnector.spec.js b/src/bot/__tests__/MessengerConnector.spec.js
index e9757946..af6cde70 100644
--- a/src/bot/__tests__/MessengerConnector.spec.js
+++ b/src/bot/__tests__/MessengerConnector.spec.js
@@ -185,6 +185,16 @@ function setup(
   };
 }
 
+const _consoleError = console.error;
+
+beforeEach(() => {
+  console.error = jest.fn();
+});
+
+afterEach(() => {
+  console.error = _consoleError;
+});
+
 describe('#platform', () => {
   it('should be messenger', () => {
     const { connector } = setup();
@@ -361,6 +371,32 @@ describe('#updateSession', () => {
       },
     });
   });
+
+  it('update session when getUserProfile() failed', async () => {
+    const { connector, mockGraphAPIClient } = setup();
+    const error = new Error('fail');
+
+    mockGraphAPIClient.getUserProfile.mockReturnValue(Promise.reject(error));
+
+    const session = {};
+    await connector.updateSession(session, request.body);
+
+    expect(mockGraphAPIClient.getUserProfile).toBeCalledWith(
+      '1412611362105802',
+      { access_token: undefined }
+    );
+    expect(session).toEqual({
+      user: {
+        _updatedAt: expect.any(String),
+        id: '1412611362105802',
+      },
+    });
+    expect(warning).toBeCalledWith(
+      false,
+      'getUserProfile() failed, `session.user` will only have `id`'
+    );
+    expect(console.error).toBeCalledWith(error);
+  });
 });
 
 describe('#mapRequestToEvents', () => {