PNI-only contacts synced from Storage Service are left with RegisteredState.UNKNOWN and never appear in New Chat
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 82/100
Research direction
Start in RecipientTable.kt at getValuesForStorageContact (around lines 4790-4797) and compare its ACI-only check with buildContentValuesForNewUser (line 4740) and ContactRecordProcessor.isInvalid (104-109). The fix is to treat a valid PNI like an ACI when deciding REGISTERED; then verify a PNI-only ContactRecord with unregisteredAtTimestamp == 0 is inserted with registered = 1 and appears in the New Chat query. Also inspect ContactDiscovery.kt:56, where refresh exits early without Contacts permission.
Written by the indexing model from the issue text.
Description
Guidelines
- I have searched open and closed issues for duplicates
- I am submitting a bug report for existing functionality that does not work as intended
- This isn't a feature request or a discussion topic
Bug description
Summary
When a valid PNI-only ContactRecord (unregisteredAtTimestamp = 0, whitelisted = true, pni/pniBinary, e164, and a name/nickname, with no aci) is synced from Storage Service, Signal-Android inserts or updates the recipient without setting RecipientTable.REGISTERED. The row stays at SQLite's default RegisteredState.UNKNOWN (0) and logs:
Contact is marked as registered, but has no serviceId! Can't locally mark registered.
Because New Chat queries (ContactSearchSelection.SIGNAL_CONTACT and getSignalOnlyContactsForIndex) require registered = 1, these contacts do not appear in the New Chat contact list. If Android Contacts permission is not granted, ContactDiscovery.refreshAll returns early (ContactDiscovery.kt:56), so neither pull-to-refresh nor DirectoryRefreshJob ever marks them registered and they stay missing indefinitely.
Why this matters
CDSv2 only returns a PNI (never an ACI) for phone numbers you haven't messaged yet, and Signal clients upload these PNI-only contacts to Storage Service (RecipientTable.getContactStorageSyncIdsMap, line 1320). This breaks any case where a PNI-only contact arrives via Storage Sync on an Android device without a subsequent CDS refresh — for example:
- Restoring an account on Android (or syncing to a linked Android device) without granting Android system Contacts permission, where previously discovered PNI-only contacts are restored from Storage Service.
- Syncing PNI-only contacts discovered on another device (e.g. Signal-iOS or a linked device). I ran into this while building a Telegram -> Signal migration tool that discovers Signal contacts via CDSv2 and writes PNI-only
ContactRecords to Storage Service. Those contacts appear immediately on Signal-iOS and Signal-Desktop, but do not appear in New Chat on Signal-Android even after pulling down to refresh.
The workaround is forcing the user to grant Contacts permission which isn't great..
Root cause
In app/src/main/java/org/thoughtcrime/securesms/database/RecipientTable.kt (getValuesForStorageContact, lines 4790–4797 on main / 8959dc6e):
put(UNREGISTERED_TIMESTAMP, contact.proto.unregisteredAtTimestamp)
if (contact.proto.unregisteredAtTimestamp > 0L) {
put(REGISTERED, RegisteredState.NOT_REGISTERED.id)
} else if (contact.proto.signalAci != null) {
put(REGISTERED, RegisteredState.REGISTERED.id)
} else {
Log.w(TAG, "Contact is marked as registered, but has no serviceId! Can't locally mark registered. (Phone: ${contact.proto.e164.nullIfBlank()}, Username: ${username?.isNotEmpty()})")
}
Line 4793 only checks contact.proto.signalAci != null and ignores contact.proto.signalPni, even though:
- The warning message itself says
has no serviceId, nothas no ACI. ContactRecordProcessor.isInvalid(ContactRecordProcessor.kt:104-109) accepts contacts with either a valid ACI or a valid PNI.- Other paths in
RecipientTable.kttreat either ACI or PNI as sufficient to mark a recipient registered or as aServiceId:buildContentValuesForNewUser(RecipientTable.kt:4740):if (pni != null || aci != null)setsREGISTERED = RegisteredState.REGISTERED.idprocessPnpTuple(RecipientTable.kt:3015-3023):PnpOperation.SetPnisetsREGISTERED = RegisteredState.REGISTERED.idapplyStorageSyncContactInsert(RecipientTable.kt:972) andapplyStorageSyncContactUpdate(RecipientTable.kt:1030):signalAci != null || signalPni != nullgetValuesForStorageContact(RecipientTable.kt:4800, 4803):contact.proto.signalAci ?: contact.proto.signalPni
Cross-client behavior (Signal-iOS & Signal-Desktop)
Both other official clients already mark PNI-only ContactRecords with unregisteredAtTimestamp == 0 as registered:
- Signal-iOS (
SignalServiceKit/StorageService/StorageServiceProto+Sync.swift:493-504) requiresAtLeastOneServiceId(aci:pni:)and unconditionally callsmarkAsRegisteredAndSavewheneverunregisteredAtTimestampis unset/0:} else { recipientManager.markAsRegisteredAndSave( &recipient, shouldUpdateStorageService: false, tx: transaction, ) } guard let serviceIds = AtLeastOneServiceId(aci: recipient.aci, pni: recipient.pni) else { owsFailDebug("Can't have a merge result without a ServiceId") return .invalid } - Signal-Desktop (
ts/services/storageRecordOps.preload.ts:1800-1804) similarly callsconversation.setRegistered({ fromStorageService: true, shouldSave: false })whenever!contactRecord.unregisteredAtTimestamp || contactRecord.unregisteredAtTimestamp === 0n, regardless of whether the record has an ACI or only a PNI.
Aligning RecipientTable.getValuesForStorageContact with buildContentValuesForNewUser (if (pni != null || aci != null)) and ContactRecordProcessor.isInvalid brings Android into line with both iOS and Desktop.
Steps to reproduce
- On a Signal-Android device without Contacts permission (or before
DirectoryRefreshJobruns), sync a Storage ServiceContactRecordthat haspni/pniBinary,e164,whitelisted = true, anickname(or name),unregisteredAtTimestamp = 0, and noacifor a user not already in the localrecipienttable. - Open New Chat on Signal-Android (and optionally pull down to refresh).
Actual result
RecipientTable.getValuesForStorageContactlogs"Contact is marked as registered, but has no serviceId! Can't locally mark registered."and omitsREGISTERED.- The recipient is inserted with
registered = 0(RegisteredState.UNKNOWN) and does not appear in New Chat. - Without Contacts permission, pulling down to refresh does not resolve it because
ContactDiscovery.refreshAllexits early.
Expected result
A ContactRecord with unregisteredAtTimestamp == 0 and a valid PNI (even without an ACI) is marked RegisteredState.REGISTERED and appears in New Chat immediately after Storage Sync, matching Signal-iOS and Signal-Desktop.
Screenshots
No response
Device
No response
Android version
No response
Signal version
No response
Link to debug log
No response
- Dominant language
- Kotlin
- Stars
- 29.7k
- Forks
- 7k
- PR merge metrics
- No merged PRs in 30d
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from signalapp/Signal-Android
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
signalapp/Signal-Android#15148 ·
Maintainers usually reply within 1 day
-
Accessibility: Reaction emoji in the long-press menu are not accessible with TalkBackPossibly taken @vlad-emelyanov claimed this 7 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
signalapp/Signal-Android#15134 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
signalapp/Signal-Android#15071 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
signalapp/Signal-Android#15050 · 3 comments · 1 reaction ·
Maintainers usually reply within 1 day
-
Samsung Keyboard: Galaxy AI stickers are sent as regular images since 7.41.0Possibly taken @actuallyrisk claimed this 53 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
signalapp/Signal-Android#15035 · 1 comment ·
Maintainers usually reply within 1 day
All issues in signalapp/Signal-Android
Similar issues
-
0. Needs triage enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
accessibility agent-ready area:android bug fleet
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
level-98/mailcrane#412 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 2 days
-
help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
DojoCodingLabs/hermit#23 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day