Skip to content

[BUG] Edited encrypted message fails to decrypt until restart #213

Description

@thomas-quant

Prerequisites

  • I have searched existing issues and found no duplicates
  • I have checked the FAQ/Wiki and found no solution

Description

After editing an encrypted message while encryption remains enabled, the edited message displays a decryption error. Restarting GoofCord causes the same edited message to decrypt correctly.

I intend to work on a fix and submit a PR.

Steps to Reproduce

  1. Enable message encryption and configure an encryption password.
  2. Enable encryption using the chat button.
  3. Send an encrypted message.
  4. Keep encryption enabled.
  5. Edit the message and save the edit.
  6. Observe the displayed message.
  7. Restart GoofCord and view the message again.

Expected Behavior

The edited encrypted message should decrypt immediately when its MESSAGE_UPDATE event is processed.

Actual Behavior

Immediately after the edit, GoofCord displays:

Decryption failed: Cannot read properties of undefined (reading 'length')

After restarting GoofCord, the edited message loads and decrypts correctly.

Screenshots

The encrypted message successfully decrypted before editing:

Encrypted message before editing

The decryption error immediately after editing:

Decryption error immediately after editing

The edited message successfully decrypted after restarting GoofCord:

Edited message after restarting

Operating System

Windows 10

GoofCord Version

2.2.2

Installation Method

Installer from GitHub Releases (.exe, .dmg, .deb, .rpm, etc.)

Additional Information

Installed using the Windows x64 .exe installer.

The outgoing pre-edit hook receives a valid channelId and successfully encrypts the edit. The failure occurs while processing the incoming MESSAGE_UPDATE.

The current handler calls:

dispatch.message.content = GoofCord.decryptMessage(
    dispatch.message.content,
    dispatch.channelId,
);

The error is consistent with dispatch.channelId being undefined when passed through the generated WASM string wrapper. The updated message itself contains dispatch.message.channel_id, which should be preferred or used as a fallback.

History loading uses a different dispatch path with a valid channel ID, explaining why restarting allows the same ciphertext to decrypt.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions