Skip to content

Commit 1433185

Browse files
committed
fix(communities): skip bloom filter generation without private key instead of erroring
A missing community private key is the expected state on devices that don't control the community, not a failure: returning an error made the caller log noise on every publish. Return nil and skip generation, as in #7622.
1 parent bc12d98 commit 1433185

2 files changed

Lines changed: 9 additions & 8 deletions

File tree

protocol/communities/community_bloom_filter.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,12 @@ import (
1313
)
1414

1515
func generateBloomFiltersForChannels(description *protobuf.CommunityDescription, privateKey *ecdsa.PrivateKey) error {
16-
// The community private key is absent on devices that don't control the
17-
// community (e.g. a freshly profile-synced device); filters can't be
18-
// generated without it.
16+
// Bloom filters require the community private key to derive the shared secret.
17+
// It is absent on devices that don't control the community (e.g. a freshly
18+
// profile-synced device), which is expected, so skip generation instead of
19+
// dereferencing a nil key.
1920
if privateKey == nil {
20-
return errors.New("private key is required to generate channel bloom filters")
21+
return nil
2122
}
2223

2324
for channelID, channel := range description.Chats {

protocol/communities/community_bloom_filter_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ func (s *CommunityBloomFilterSuite) TestBasic() {
6868

6969
// Regression test: on a device that does not hold the community private key
7070
// (e.g. right after a profile sync), the publish path can still reach
71-
// generateBloomFiltersForChannels with a nil key. It must return an error
72-
// (the caller logs it and marshals the description without filters) instead
73-
// of crashing the node in ECDH.
71+
// generateBloomFiltersForChannels with a nil key. Filter generation must be
72+
// skipped so the description is marshaled without filters, instead of crashing
73+
// the node in ECDH.
7474
func (s *CommunityBloomFilterSuite) TestNilPrivateKey() {
7575
memberIdentity, err := crypto.GenerateKey()
7676
s.Require().NoError(err)
@@ -101,6 +101,6 @@ func (s *CommunityBloomFilterSuite) TestNilPrivateKey() {
101101
s.Require().NotPanics(func() {
102102
err = generateBloomFiltersForChannels(description, nil)
103103
})
104-
s.Require().Error(err)
104+
s.Require().NoError(err)
105105
s.Require().Nil(description.Chats[encryptedChannelID].MembersList)
106106
}

0 commit comments

Comments
 (0)