Skip to content

Commit

Permalink
[keyserver] Make sure we don't call fetchServerThreadInfos with empty…
Browse files Browse the repository at this point in the history
… threadIDs

Summary:
This diff fixes a regression introduced in D8509. We should never specify an empty `threadIDs` parameter to the `FetchThreadInfosFilter` we pass to `fetchServerThreadInfos`.

This diff addresses an urgent regression – see [ENG-4529](https://linear.app/comm/issue/ENG-4529/sql-error-breaking-message-sends) for details.

Test Plan: I confirmed that created a message in a thread with an @-tag of somebody who is already in the thread does not cause the error described in the linked task

Reviewers: atul, tomek, michal, bartek, kamil, inka, ginsu, varun

Reviewed By: tomek

Differential Revision: https://phab.comm.dev/D8651
  • Loading branch information
Ashoat committed Jul 28, 2023
1 parent a578681 commit c057590
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions keyserver/src/fetchers/thread-fetchers.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ type FetchServerThreadInfosResult = {
async function fetchServerThreadInfos(
filter?: FetchThreadInfosFilter,
): Promise<FetchServerThreadInfosResult> {
if (filter?.threadIDs?.size === 0) {
return { threadInfos: {} };
}

let primaryFetchClause;
if (filter?.accessibleToUserID) {
primaryFetchClause = SQL`
Expand Down
1 change: 1 addition & 0 deletions keyserver/src/updaters/thread-permission-updaters.js
Original file line number Diff line number Diff line change
Expand Up @@ -1074,6 +1074,7 @@ async function commitMembershipChangeset(
});
}
}

for (const row of membershipRowMap.values()) {
const { userID, threadID } = row;
if (row.operation === 'delete' || row.role === '-1') {
Expand Down

0 comments on commit c057590

Please sign in to comment.