Exporting multiple groups with identical names causes invalid JSON due to formatting issues
When exporting multiple groups at once, if two or more groups, channels, or contacts share the same name, the resulting JSON file becomes invalid due to formatting issues. The export process attempts to add both groups/channels to the same file simultaneously, causing the formatting to break.
I'm not sure I understand. sigtop does not write to existing files; it will fail with a file exists error instead.
Can you clarify? What command have you run? Exactly how does the formatting break?
I ran the command:
sigtop export-messages -f json
If there are multiple Signal channels with the same name (e.g., "Channel1" and "Channel1"), the resulting JSON file (Channel1.json) has a formatting issue.
In the exported file, the first batch of messages from "Channel1" is formatted correctly and enclosed within an array ([]). However, once the export reaches messages from another channel with the same name, the file structure breaks:
- The first set of messages is properly closed with ].
- Instead of starting a new valid JSON array, the second batch of messages begins abruptly, missing the opening [ bracket.
- The new messages have a different conversationId, meaning they belong to a separate channel but are incorrectly appended to the same file.
Example:
[
{
... normal JSON objects ...
}
]
// First set of messages from "Channel1" ends correctly
// A new message appears without a proper array structure
":false,"messageId":""},"reactions": ...
}
]
This results in an invalid JSON structure, making it impossible to parse the file correctly.
// A new message appears without a proper array structure ":false,"messageId":""},"reactions": ...
Does the "second batch" really start in the middle of a JSON object? In other words, is the opening { missing?
In your other issue you wrote you were exporting to an exFAT disk. Does the corruption also occur when you export to your ext4 filesystem?
Also, do you get an open Channel1 (group).json: file exists error when you export to the exFAT disk?
The error file exists only happens on my ext4 filesystem.
The second batch starts in the middle of a JSON object, the { is missing as shown in the example, but only seem to happen on the exFAT disk.
I replied by email but GitHub is unreliable. New attempt:
I'm very busy at the moment. Sorry. I'll get back to you as soon as possible.
You are running into two separate problems.
The first problem is that sigtop tries to export groups with identical names to the same file. This has now been fixed: groups with identical names are now exported to different files.
The second problem appears to be a bug in your operating system. sigtop uses the os.O_EXCL flag to prevent existing files from being overwritten. This flag works correctly on your ext4 filesystem, but it is ignored on your exFAT filesystem.