← Back to Pull requests

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

Closed
unknown closed this pull request without merging on Nov 16, 2026 21:27 UTC
View on GitHub
unknown unknown commented on Nov 04, 2026 21:35 UTC
Author

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.

    Diff: 289 lines (+216 / -73) across 3 files Reviewer: tonygermano Review duration: 17271m
    All Vouch review confidence checks passed
    Residual risk 0.16 = Change Risk (0.40) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.40 · 289 lines diff across 3 files
    0.40
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.339
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #562"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 39.8% (MEDIUM) · Higher = larger blast radius
    39.8%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 15.7% · Safe to merge
    15.7%