sigtop icon indicating copy to clipboard operation
sigtop copied to clipboard

Exporting multiple groups with identical names causes invalid JSON due to formatting issues

Open jsmith67438 opened this issue 10 months ago • 5 comments

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.

jsmith67438 avatar Feb 20 '25 09:02 jsmith67438

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?

tbvdm avatar Feb 21 '25 22:02 tbvdm

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:

  1. The first set of messages is properly closed with ].
  2. Instead of starting a new valid JSON array, the second batch of messages begins abruptly, missing the opening [ bracket.
  3. 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.

jsmith67438 avatar Feb 25 '25 09:02 jsmith67438

// 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?

tbvdm avatar Feb 26 '25 09:02 tbvdm

Also, do you get an open Channel1 (group).json: file exists error when you export to the exFAT disk?

tbvdm avatar Feb 26 '25 10:02 tbvdm

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.

jsmith67438 avatar Feb 27 '25 10:02 jsmith67438

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.

tbvdm avatar Mar 11 '25 18:03 tbvdm

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.

tbvdm avatar Jul 30 '25 19:07 tbvdm