(wip) feat(optimizer): bound list-API responses with configurable limit#595
Draft
mkuchenbecker wants to merge 1 commit into
Draft
(wip) feat(optimizer): bound list-API responses with configurable limit#595mkuchenbecker wants to merge 1 commit into
mkuchenbecker wants to merge 1 commit into
Conversation
All four list-style endpoints now require a bounded limit. - New ApiListLimitProperties carries default-limit (10) and max-limit (1000), both configurable via optimizer.api.list.*. - Controllers accept Integer limit (nullable → default), validate via ResponseStatusException(BAD_REQUEST) on out-of-range. - listTableOperations / listTableStats lose their service-level @value("${optimizer.repo.default-limit}") fallback and now take limit as a required arg. The repo Pageable already cascades limit to LIMIT n in SQL. - New MockMvc ListLimitControllerTest covers default-applies, explicit limit, zero/over-max rejection, with @TestPropertySource confirming bounds are config-driven (not hard-coded). No pagination — implicit len(result) == limit signals "more available." Cursor pagination can land later if needed; offset/limit deliberately avoided. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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.
Status
(WIP) — inspection branch on top of
mkuchenb/optimizer-2(PR #531). Open for review of the diff shape before folding into #531.Summary
All four list-style endpoints on the optimizer REST API now require a bounded
limit. Default 10, max 1000, both configurable.GET /v1/optimizer/operationsGET /v1/optimizer/statsGET /v1/optimizer/operations-history/{tableUuid}GET /v1/optimizer/stats/{tableUuid}/historyChanges
ApiListLimitProperties(@ConfigurationProperties("optimizer.api.list")) —defaultLimit=10,maxLimit=1000, with avalidateAndResolve(Integer)helper that throwsResponseStatusException(BAD_REQUEST)on out-of-range.@RequestParam(required = false) Integer limit, calllimits.validateAndResolve(limit)at method entry.OptimizerDataService—listTableOperationsandlistTableStatsgainint limit(the two history methods already had it).OptimizerDataServiceImpl— drops@Value("${optimizer.repo.default-limit:10000}"); threads the caller-supplied limit straight intoPageRequest.of(0, limit), which Spring Data translates to MySQLLIMIT n.application.properties—optimizer.repo.default-limit=10000removed; replaced withoptimizer.api.list.default-limit=10+max-limit=1000.Design notes
len(result) == limitsignal tells callers there may be more. Cursor-based pagination can land later if needed. Offset/limit pagination is deliberately avoided (deep-scan cost, skip/duplicate under concurrent writes).@TestPropertySourceto confirm the bound is config-driven, not hard-coded.ResponseStatusException(BAD_REQUEST)rather thanIllegalArgumentExceptionbecause Spring does not auto-map the latter to 400.Testing Done
./gradlew :services:optimizer:test— all green.New
ListLimitControllerTest(10 MockMvc cases): default applies, explicit limit honored,limit=0→ 400,limit > max→ 400, across all four endpoints.@TestPropertySourcesetsdefault-limit=3, max-limit=50to verify config-driven behavior.New service-layer cases:
listTableOperations_respectsLimitandlistTableStats_respectsLimitconfirm thePageRequestcap reaches the repo.🤖 Generated with Claude Code