You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG] Message export fails with a NullPointerException when a password is given without an encryption type #591
A message export that is given a password but no encryptionType fails with HTTP 500 and a NullPointerException, with nothing logged in mirth.log. Both export variants do this since #586 merged.
Steps
Call POST /channels/{channelId}/messages/_export with archiveFormat=zip and password=secret, and no encryptionType. The same happens through _exportUsingFilter when passwordEnabled is true and encryptionType is missing.
Look at the response.
Expected
The request is rejected with a message that says encryptionType is required with a password, or the type has a documented default. Nothing is written.
Actual
HTTP 500 with a NullPointerException and no log entry.
Before #580, an empty hidden .export.zip was also left in the export folder. #580 now deletes the file it was building when archiving fails, so it should no longer be left behind. Claude did not re-check this on current main.
Cause
encryptionType is optional and has no default. In ArchiveUtils.createFolderArchive, a null type counts as AES (encryptionType != EncryptionType.STANDARD), so it reaches encryptionType.getKeyStrength() and throws.
Until #586, the query-parameter variant never enabled the password, so it ignored it and wrote an unprotected ZIP with a 200. _exportUsingFilter already failed this way. #586 made the query-parameter variant fail the same way, which is safer than an unprotected archive but gives a poor error. The report is in the review of #586.
Suggested fix
Reject a password without an encryptionType up front in MessageWriterFactory, with a message naming the missing parameter. That covers both variants and writes nothing. Defaulting to AES-256 would also work, but it chooses a cipher for the caller.
Put the check next to the existing unsupported-format check from #580, and use the same condition (isPasswordEnabled() and a non-blank password). A blank password is already ignored and never reaches the NullPointerException, so a check that fired on it would turn today's plain ZIP into an error. Whether a blank password should be rejected or used is a separate decision, tracked in #609 (the blank-password issue).
Tests, for both variants through MessageWriterFactory or the servlet tests:
A password with no encryptionType is rejected and nothing is written.
A blank password with no encryptionType still produces a plain ZIP.
Claude checked: the cause by reading ArchiveUtils and MessageWriterOptions, and that a blank password skips the archive encryption in the code. The 500 was reported in the review of #586 and was not reproduced by Claude.
Activity