signalapp / signalapp/Signal-Android
Cannot create v2 backups: NullPointerException in requireNonNullBlob()
Nobody has claimed this yet.
- Dominant language
- Kotlin
- Stars
- 29.4k
- Forks
- 6.9k
- PR merge metrics
- No merged PRs in 30d
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
On an old phone, after upgrading to v2 backups, Signal is no longer able to create backups. It used to be able to create "v1" backups (.backup files) without problems.
This is the relevant part of the debug log (I'm not at liberty to share the full debug log, but more information can be provided on request):
[8.17.4] [4242 ] 2026-07-06 16:13:46.593 GMT+02:00 W LocalArchiveJob: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Class java.lang.Object.getClass()' on a null object reference
[8.17.4] [4242 ] 2026-07-06 16:13:46.593 GMT+02:00 W LocalArchiveJob: at org.signal.core.util.CursorExtensionsKt.requireNonNullBlob(CursorExtensions.kt:62)
[8.17.4] [4242 ] 2026-07-06 16:13:46.593 GMT+02:00 W LocalArchiveJob: at org.thoughtcrime.securesms.database.AttachmentTable.getLocalArchivableAttachments(AttachmentTable.kt:628)
[8.17.4] [4242 ] 2026-07-06 16:13:46.593 GMT+02:00 W LocalArchiveJob: at org.thoughtcrime.securesms.backup.v2.BackupRepository.$r8$lambda$-JkYeh5kBb-_Hj7tMEfN6Eqopns(BackupRepository.kt:789)
[8.17.4] [4242 ] 2026-07-06 16:13:46.593 GMT+02:00 W LocalArchiveJob: at org.thoughtcrime.securesms.backup.v2.BackupRepository$$ExternalSyntheticLambda36.invoke(R8$$SyntheticClass:0)
[8.17.4] [4242 ] 2026-07-06 16:13:46.593 GMT+02:00 W LocalArchiveJob: at org.thoughtcrime.securesms.backup.v2.BackupRepository.export(BackupRepository.kt:1101)
[8.17.4] [4242 ] 2026-07-06 16:13:46.593 GMT+02:00 W LocalArchiveJob: at org.thoughtcrime.securesms.backup.v2.BackupRepository.exportForLocalBackup(BackupRepository.kt:777)
[8.17.4] [4242 ] 2026-07-06 16:13:46.593 GMT+02:00 W LocalArchiveJob: at org.thoughtcrime.securesms.backup.v2.local.LocalArchiver.export(LocalArchiver.kt:84)
[8.17.4] [4242 ] 2026-07-06 16:13:46.593 GMT+02:00 W LocalArchiveJob: at org.thoughtcrime.securesms.jobs.LocalArchiveJob.run(LocalArchiveJob.kt:102)
[8.17.4] [4242 ] 2026-07-06 16:13:46.593 GMT+02:00 W LocalArchiveJob: at org.thoughtcrime.securesms.jobmanager.JobRunner.run(JobRunner.java:99)
[8.17.4] [4242 ] 2026-07-06 16:13:46.593 GMT+02:00 W LocalArchiveJob: at org.thoughtcrime.securesms.jobmanager.JobRunner.run(JobRunner.java:62)
This is the relevant part of AttachmentTable.kt:
617 fun getLocalArchivableAttachments(): List<LocalArchivableAttachment> {
618 return readableDatabase
619 .select(*PROJECTION_WITH_METADATA)
620 .from(TABLE_NAME_WITH_METADTA)
621 .where("$DATA_HASH_END IS NOT NULL AND $DATA_FILE IS NOT NULL AND ${AttachmentMetadataTable.TABLE_NAME}.${AttachmentMetadataTable.LOCAL_BACKUP_KEY} IS NOT NULL")
622 .orderBy("$TABLE_NAME.$ID DESC")
623 .run()
624 .readToList {
625 LocalArchivableAttachment(
626 attachmentId = AttachmentId(it.requireLong(ID)),
627 file = File(it.requireNonNullString(DATA_FILE)),
628 random = it.requireNonNullBlob(DATA_RANDOM),
629 size = it.requireLong(DATA_SIZE),
630 localBackupKey = AttachmentMetadataTable.getMetadata(it)!!.localBackupKey!!,
631 plaintextHash = Base64.decode(it.requireNonNullString(DATA_HASH_END)),
632 contentType = it.requireString(CONTENT_TYPE)
633 )
634 }
635 }
The phone contains old attachments that are encrypted with ClassicDecryptingPartInputStream. For these attachments, the DATA_RANDOM column is NULL. I expect this is the problem.
Would it be possible to fix this one way or the other so that Signal on this phone can create backups again?
Thanks.
Screenshots
No response
Device
No response
Android version
No response
Signal version
No response
Link to debug log
No response
Contributor 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.
Research direction
Start in AttachmentTable.kt at getLocalArchivableAttachments(), then read CursorExtensions.kt around requireNonNullBlob() and the BackupRepository.kt export path shown in the stack trace. Reproduce or inspect backup creation with legacy attachments whose DATA_RANDOM is NULL; done means v2 local backups complete without this exception, with appropriate coverage if existing backup tests are found.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, kotlin
- Domain
- database, mobile
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 58/100