Skip to content

Reject a channel name over 40 characters before saving it (fixes #610) - #621

Open
iacsha wants to merge 1 commit into
OpenIntegrationEngine:mainfrom
iacsha:fix/610-channel-name-length
Open

iacsha wants to merge 1 commit into
OpenIntegrationEngine:mainfrom
iacsha:fix/610-channel-name-length

Conversation

@iacsha

@iacsha iacsha commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

Fixes #610.

CHANNEL.NAME is VARCHAR(40) in every supported database (Derby, MySQL, Oracle, PostgreSQL; NVARCHAR(40) on SQL Server), but the server never checked the length. A longer name, which is easy to get by cloning a channel that already has a long name, failed in the INSERT. That SQLException then couldn't be serialized into the response either, so clients only saw "Request failed".

Change

  • DefaultChannelController.updateChannel rejects a name over 40 characters before anything is written, with Channel name must be at most 40 characters. It's a ControllerException, the same way the method already rejects a duplicate name ("A channel with that name already exists"), so every client gets the message through the existing error path.
  • The limit lives in a new Channel.MAX_NAME_LENGTH, next to the existing ChannelTag.MAX_NAME_LENGTH, and the Swing channel editor now uses it instead of its own literal 40.

Not in this PR

  • The status is still 500, like the duplicate-name error. If you'd rather return 400 for validation errors from the channel servlet, I'm happy to do that here or separately.
  • The second point in the issue, that no SQLException can be serialized on Java 9+ without --add-opens=java.sql/java.sql=ALL-UNNAMED (the reporter verified that it lets the real database error through), affects every database error returned by the API. Changing default_modules.vmoptions felt like your call rather than part of this fix.

Testing

  • New DefaultChannelControllerNameTest (a name at the limit, the 46-character clone name from the issue, a missing name). :server:test and :client:compileJava pass.
  • Live, against a server built from main (Derby): creating a channel named Copy of TEST credentials via Configuration Map through POST /api/channels returns an HTML HTTP ERROR 500 Request failed., and the log shows the InaccessibleObjectException from serializing the SQLException.
  • The same request against this branch:
<com.mirth.connect.client.core.ControllerException>
  <detailMessage>Channel name must be at most 40 characters</detailMessage>
  ...

Nothing is written to the database and nothing is logged as an error.

…IntegrationEngine#610)

CHANNEL.NAME is VARCHAR(40) in every supported database, but the server never
checked the length, so a longer name (easy to get by cloning a channel with a
long name) failed in the INSERT. That SQLException then could not be
serialized into the response either, so clients only saw "Request failed".

updateChannel now rejects such a name up front with "Channel name must be at
most 40 characters", the same way it already rejects a duplicate name. The
limit lives in Channel.MAX_NAME_LENGTH, which the Swing channel editor now uses
instead of its own literal 40.

Signed-off-by: iacsha <122627209+iacsha@users.noreply.github.com>
@github-actions

github-actions Bot commented Dec 3, 2026

Copy link
Copy Markdown

Test Results

  152 files  +1    152 suites  +1   5m 9s ⏱️ +51s
1 040 tests +3  1 040 ✅ +3  0 💤 ±0  0 ❌ ±0 
1 418 runs  +3  1 412 ✅ +3  6 💤 ±0  0 ❌ ±0 

Results for commit 923e3b9. ± Comparison against base commit c63eed8.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Saving a channel with a name over 40 characters fails with an opaque "Request failed" (SQL error not returned)

1 participant