Skip to content

Commit

Permalink
connector/sync: fix NPE when syncing channels
Browse files Browse the repository at this point in the history
Before this change syncChannels would NPE if inboxData.Conversations was
nil due to being omitted because it's empty.

This change ensures that the Conversations map is not nil before copying
to it.

Signed-off-by: Sumner Evans <[email protected]>
  • Loading branch information
sumnerevans committed Jan 14, 2025
1 parent 40c3f56 commit c36c257
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/connector/client_sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,13 @@ func (tc *TwitterClient) syncChannels(ctx context.Context, initialInboxState *re
break
}

if inboxData.Conversations == nil {
inboxData.Conversations = map[string]types.Conversation{}
}
maps.Copy(inboxData.Conversations, nextInboxTimelineResponse.InboxTimeline.Conversations)
if inboxData.Users == nil {
inboxData.Users = map[string]types.User{}
}
maps.Copy(inboxData.Users, nextInboxTimelineResponse.InboxTimeline.Users)
inboxData.Entries = append(inboxData.Entries, nextInboxTimelineResponse.InboxTimeline.Entries...)

Expand Down

0 comments on commit c36c257

Please sign in to comment.