Skip to content

fix: Honor the password in the query-parameter message export - #586

Merged
tonygermano merged 1 commit into
OpenIntegrationEngine:mainfrom
tonygermano:fix/export-query-password
Nov 28, 2026
Merged

tonygermano merged 1 commit into
OpenIntegrationEngine:mainfrom
tonygermano:fix/export-query-password

Conversation

@tonygermano

Copy link
Copy Markdown
Member

Fixes #582

The variant of the server-side message export that takes query parameters copied the password and encryption type into the writer options but never enabled the password. MessageWriterFactory only protects an archive when the password is enabled, so a request for a password-protected ZIP wrote an unprotected one without any error. The variant that takes the options in the request body, which the administrator uses, was not affected.

This enables the password when one is given.

The fix is a single line in MessageServlet.getMessageWriterOptions, with tests in MessageServletTest for a password, no password and an empty password. The first fails without the change.

Claude checked:

  • ./gradlew clean build dist passes on this branch.
  • On a server built from oie/main, POST /api/channels/{channelId}/messages/_export with archiveFormat=zip, password=secret and encryptionType=AES256 as query parameters wrote a ZIP whose entries are not encrypted.
  • On a server built from this branch, the same request writes entries with the encrypted flag set and the AES method, and an empty password still writes a plain ZIP.

Release notes

  • Fixed the query-parameter variant of the server-side message export ignoring the password parameter and writing an unprotected ZIP.

🤖 Drafted with Claude Code

@tonygermano tonygermano added the bug Something isn't working label Nov 16, 2026
@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Test Results

  147 files  ±0    147 suites  ±0   4m 1s ⏱️ +9s
1 008 tests +2  1 008 ✅ +2  0 💤 ±0  0 ❌ ±0 
1 332 runs  +2  1 326 ✅ +2  6 💤 ±0  0 ❌ ±0 

Results for commit 75c52f6. ± Comparison against base commit 1ad22b1.

♻️ This comment has been updated with latest results.

@pacmano1 pacmano1 left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Live-tested a build of this branch against main. password=secret&encryptionType=AES256 now writes AES-encrypted entries; main writes them plain.

But password without encryptionType now fails: HTTP 500 with a NullPointerException, nothing in mirth.log, and an empty .export.zip left in the export folder. Main returns 200 with a plain ZIP. encryptionType isn't required and has no default, so a password alone is a valid request and now crashes.

_exportUsingFilter already does this on main when passwordEnabled is true and there's no encryptionType: same 500, same error text, same empty .export.zip. So the missing type needs handling where both variants end up: default it, or fail with a message that says encryptionType is needed.

Co-authored with Claude Code.

@tonygermano

Copy link
Copy Markdown
Member Author

@pacmano1 since it sounds like that is a preexisting bug, can it be handled in a follow-up PR? This PR was to stop it from producing an unencrypted zip when the parameters were passed in correctly for it to encrypt. Failing on bad input in the same way that another working method fails instead of silently producing wrong output sounds like this is meeting its goal.

@tonygermano

Copy link
Copy Markdown
Member Author

@pacmano1 Thanks for testing this. You're right that password without encryptionType now fails with an unhelpful error: a NullPointerException, nothing in the log, and an empty .export.zip left behind.

I still think failing is the right direction for this PR. A request that asks for a password-protected archive used to get a plain ZIP with no error, and that is the bug here. A loud failure is safer than an archive that looks protected and isn't, and the leftover file is empty. The message is what's wrong, not the outcome.

The missing-encryptionType case isn't new. It already happens on main in _exportUsingFilter when passwordEnabled is true, so it affects both variants and I'd rather not widen this fix. I've opened an issue for it so someone can pick it up: #591.

The fix probably belongs in MessageWriterFactory, which #580 also changes to reject a password for formats that can't be protected. Whoever takes it should expect a conflict with #580, and may prefer to build on it or wait for it to merge.

Claude checked the cause in ArchiveUtils: a null type counts as AES (encryptionType != STANDARD), so it reaches encryptionType.getKeyStrength(). Claude did not reproduce the 500 itself.


🤖 Drafted with Claude Code

@pacmano1 pacmano1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fine with #591 as the follow-up.

@NicoPiel NicoPiel left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nits

  1. Whitespace-only passwords. The PR uses isNotEmpty, but MessageWriterFactory line 52 and ArchiveUtils use isNotBlank. A password of " " gets enabled, then skipped by both, so a plain ZIP is written with no error. Using isNotBlank would make the three checks agree.
  2. Brittle test helper. exportWithQueryParameters calls a method with about 50 positional arguments. It works, but any change to the signature breaks it. Not worth blocking on.

The variant of the server-side message export that takes query parameters
copied the password and encryption type into the writer options but never
enabled the password. MessageWriterFactory only protects an archive when the
password is enabled, so a request for a password-protected ZIP wrote an
unprotected one without any error. The variant that takes the options in the
request body, which the administrator uses, was not affected.

Enable the password when one is given.

Tests: the options the controller receives for a password, no password and an
empty one; the first fails without the change.

Issue: OpenIntegrationEngine#582
Assisted-by: Claude:claude-sonnet-5-5
Signed-off-by: Tony Germano <tony@germano.name>
@tonygermano
tonygermano force-pushed the fix/export-query-password branch from 3b08062 to 75c52f6 Compare November 28, 2026 01:41
@tonygermano
tonygermano merged commit 75c52f6 into OpenIntegrationEngine:main Nov 28, 2026
12 checks passed
@tonygermano
tonygermano deleted the fix/export-query-password branch November 28, 2026 03:00
@tonygermano

Copy link
Copy Markdown
Member Author

@NicoPiel Thanks for the review. I merged before replying, but below is the reasoning.

  1. Whitespace-only passwords: the checks do differ, but the archive comes out the same. With isNotEmpty the password is enabled and then skipped as blank by MessageWriterFactory and ArchiveUtils. With isNotBlank it is never enabled. Either way a plain ZIP is written, and TAR is the same because the unsupported-format check also skips a blank password. Ignoring a blank password is existing behavior in the archive code, and this PR doesn't change it, so I left it. Whether a blank password should be rejected, used or kept ignored is a behavior decision, so I opened [BUG] Message export writes an unprotected archive when the password is blank #609 for it.
  2. Test helper: I left it as is. The long argument list comes from the servlet's own overload, which the test has to call, and exportWithQueryParameters is the only place that call is made, so a signature change breaks one line. Replacing it would mean changing the servlet, which is outside this fix. I also noticed when opening the PR the obscene number of arguments on that method call.

🤖 Drafted with Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Query-parameter message export ignores the password and writes an unprotected ZIP

4 participants