fix(web): validate usage summary date range - #46
Closed
iscekic wants to merge 1 commit into
Closed
Conversation
iscekic
marked this pull request as draft
September 6, 2026 14:29
iscekic
force-pushed
the
kwf/surface-backend-services-app-9472
branch
from
September 6, 2026 14:42
f75b4e0 to
e05262d
Compare
iscekic
force-pushed
the
kwf/surface-backend-services-app-9472
branch
from
September 6, 2026 14:50
e05262d to
e68ecdf
Compare
Surface: backend services (apps/web server routes and lib). The usage summary endpoint accepts a date range but does not validate it: an end date before the start date returns a confusing empty result instead of a 400. Reproduce first against the live dev backend with two requests (a valid range and an inverted one). If it already returns a clear 400, stop with the evidence and no code change. If it does not, return a 400 with a specific message, keep the existing response shape for valid ranges, add a test beside the existing route tests, and prove both paths live in the PR body.
iscekic
force-pushed
the
kwf/surface-backend-services-app-9472
branch
from
September 6, 2026 14:53
e68ecdf to
b201593
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Request
Request
Surface: backend services (apps/web server routes and lib).
The usage summary endpoint accepts a date range but does not validate it: an end date before the start date returns a confusing empty result instead of a 400. Reproduce first against the live dev backend with two requests (a valid range and an inverted one). If it already returns a clear 400, stop with the evidence and no code change. If it does not, return a 400 with a specific message, keep the existing response shape for valid ranges, add a test beside the existing route tests, and prove both paths live in the PR body.
Changelog for users
endDate must not be before startDatewhen the requested end date is before the start date, instead of a silently empty result.Changelog for maintainers
superRefinethat attaches a customendDateissue with messageendDate must not be before startDatewheneverendDateis earlier thanstartDate; the existing tRPC input parsing already surfaces this asBAD_REQUEST, so no router code changed.endDatepath, valid and equal-instant ranges stay accepted, andgetSummaryrejects inverted input withBAD_REQUESTwithout calling the Snowflake statement mock.E2E proof
[e1] The usage summary endpoint accepts a date range but does not validate it: an end date before the start date returns a confusing empty result instead of a 400. — Recording e1-date-range.webm; final e1-both-responses.png (also e1-valid-range.png, e1-inverted-range.png, e1-valid-range.json, e1-inverted-range.json). Authenticated POST /api/trpc/usageAnalytics.getSummary: valid start=2026-06-04 end=2026-06-05 returned HTTP 500 INTERNAL_SERVER_ERROR 'Usage data…
e1-date-range.webm.trim.mp4