Skip to content

Return 400 instead of 404 for a malformed date query parameter (fixes #159) - #562

Merged
tonygermano merged 1 commit into
OpenIntegrationEngine:mainfrom
iacsha:fix/159-date-param-400
Nov 16, 2026
Merged

tonygermano merged 1 commit into
OpenIntegrationEngine:mainfrom
iacsha:fix/159-date-param-400

Conversation

@iacsha

@iacsha iacsha commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Return 400 instead of 404 for a malformed date query parameter (fixes #159)

Problem

GET /api/channels/{channelId}/messages (and the other message endpoints) take
startDate/endDate as @QueryParam Calendar, converted by
CalendarParamConverterProvider. On a malformed date, fromString throws
ProcessingException, which Jersey surfaces as 404 Not Found:

GET /api/channels/{id}/messages?startDate=1985   ->   404 { "message": "Not Found" }

404 is misleading for a bad parameter value — the caller should get a 400 that says
what was wrong.

Fix

Throw BadRequestException (400) from the converter, with a message naming the value and
the expected format:

} catch (DateTimeParseException e) {
    throw new BadRequestException("Invalid date '" + value + "'. Expected format yyyy-MM-dd'T'HH:mm:ss.SSSZ, for example 1985-10-26T09:00:00.000-0700.", e);
}

JAX-RS honors a WebApplicationException thrown from a ParamConverter (and no
ExceptionMappers are registered that would override it), so the response status is 400.
Valid dates are unaffected.

Tests

CalendarParamConverterProviderTest:

  • null returns null
  • a valid date round-trips (fromString then toString)
  • a malformed date throws BadRequestException with status 400

./gradlew :server:test --tests "*CalendarParamConverterProviderTest*" → 3 tests, 0 failures.

Note on verification

The project has no Jersey HTTP test harness, so this is verified at the converter level —
the same approach as the existing MetaDataSearchParamConverterProviderTest. The
HTTP-level 400 follows from JAX-RS WebApplicationException handling as described above.

Release Note

The message API returns 400 instead of 404 for a malformed date

A startDate or endDate query parameter that isn't in the format yyyy-MM-dd'T'HH:mm:ss.SSSZ now gets a 400 Bad Request instead of a 404 Not Found. This applies to every message endpoint that takes these parameters, such as GET /api/channels/{channelId}/messages. The response message names the value that was rejected and shows the expected format, for example 1985-10-26T09:00:00.000-0700. Valid dates work as before. (#159, #562)

If a script treated the 404 from a bad date as "channel not found", update it to check for 400 as well.

@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.

License file header, otherwise LGTM.

@tonygermano
tonygermano force-pushed the fix/159-date-param-400 branch from f89224f to 1468ea2 Compare November 4, 2026 22:20
iacsha added a commit to iacsha/engine that referenced this pull request Nov 5, 2026
Per review feedback on OpenIntegrationEngine#562, replace the copied Mirth Corporation
boilerplate header with the SPDX form used for new files.
@iacsha

iacsha commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @NicoPiel and @tonygermano. Switched the new test file to the SPDX header, using the collective Open Integration Engine Contributors form (no per-file email). Done in 6abb13b.

iacsha added a commit to iacsha/engine that referenced this pull request Nov 6, 2026
Per review feedback on OpenIntegrationEngine#562, replace the copied Mirth Corporation
boilerplate header with the SPDX form used for new files.

Signed-off-by: iacsha <122627209+iacsha@users.noreply.github.com>
@iacsha
iacsha force-pushed the fix/159-date-param-400 branch from 6abb13b to 4a48ac6 Compare November 6, 2026 19:47
@github-actions

github-actions Bot commented Nov 7, 2026 •

Copy link
Copy Markdown

Test Results

  143 files  +1    143 suites  +1   4m 5s ⏱️ +49s
  961 tests +3    961 ✅ +3  0 💤 ±0  0 ❌ ±0 
1 243 runs  +3  1 237 ✅ +3  6 💤 ±0  0 ❌ ±0 

Results for commit c30763c. ± Comparison against base commit dcd48b9.

♻️ This comment has been updated with latest results.

@mgaffigan mgaffigan 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.

"Open Integration Engine Contributors" is not a legal entity. Until you sign an ECA, you individually retain copyright and are issuing an MPL-2 license. Approval since this has happened otherwise, and your git commit already signs your name and email.

@iacsha

iacsha commented Nov 11, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @mgaffigan, understood. I've since signed the ECA (2026-11-08), and the eclipsefdn/eca check passes on this PR.

…penIntegrationEngine#159)

CalendarParamConverterProvider threw ProcessingException on an unparseable startDate/endDate, which Jersey surfaced as 404. Throw BadRequestException (400) with the value and expected format so the caller learns why the request failed.

Signed-off-by: iacsha <122627209+iacsha@users.noreply.github.com>
Signed-off-by: Tony Germano <tony@germano.name>
@tonygermano
tonygermano force-pushed the fix/159-date-param-400 branch from 4a48ac6 to c30763c Compare November 16, 2026 21:14
@tonygermano
tonygermano merged commit c30763c into OpenIntegrationEngine:main Nov 16, 2026
12 checks passed
@tonygermano tonygermano added this to the Next Release milestone Nov 16, 2026
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] HTTP 404 error (Not Found) reported for unrecognized date input to API

5 participants