Skip to content

feat: Add pagination max page size configuration#436

Merged
wschurman merged 1 commit intomainfrom
wschurman/02-12-feat_add_pagination_max_page_size_configuration
Feb 16, 2026
Merged

feat: Add pagination max page size configuration#436
wschurman merged 1 commit intomainfrom
wschurman/02-12-feat_add_pagination_max_page_size_configuration

Conversation

@wschurman
Copy link
Member

@wschurman wschurman commented Feb 13, 2026

Why

Currently, the Entity pagination system allows clients to request arbitrarily large page sizes using the first or last parameters in pagination queries. This can lead to:

  • Performance degradation when clients request excessively large pages
  • Potential memory issues on the server
  • Unpredictable query response times
  • Difficulty in capacity planning and resource allocation

By adding configurable max page size limits, we can:

  • Protect backend services from resource exhaustion
  • Ensure predictable performance characteristics
  • Provide better control over API usage patterns
  • Maintain backward compatibility (no limit by default)

How

The implementation adds a paginationMaxPageSize configuration option to the PostgresEntityDatabaseAdapterProvider that flows through the adapter hierarchy:

  1. Configuration Interface: Added PostgresEntityDatabaseAdapterConfiguration with an optional paginationMaxPageSize field
  2. Provider Level: PostgresEntityDatabaseAdapterProvider constructor now accepts the configuration object
  3. Adapter Level:
    • BasePostgresEntityDatabaseAdapter defines a paginationMaxPageSize getter (defaults to undefined)
    • PostgresEntityDatabaseAdapter overrides it to return the configured value
  4. Validation: EntityKnexDataManager.loadPageAsync validates first/last parameters against the max page size before executing queries

The validation throws descriptive errors when limits are exceeded:

  • "first must not exceed maximum page size of {limit}"
  • "last must not exceed maximum page size of {limit}"

Usage example:

const provider = new PostgresEntityDatabaseAdapterProvider({
  paginationMaxPageSize: 100
});

Test Plan

Added comprehensive unit tests in EntityKnexDataManager-test.ts.

@codecov
Copy link

codecov bot commented Feb 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (f72cbca) to head (b4c15d5).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #436   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          109       109           
  Lines        16045     16086   +41     
  Branches      1410      1419    +9     
=========================================
+ Hits         16045     16086   +41     
Flag Coverage Δ
integration 27.13% <72.09%> (+0.11%) ⬆️
unittest 95.05% <60.46%> (+0.72%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@wschurman wschurman force-pushed the wschurman/02-12-feat_add_pagination_max_page_size_configuration branch from a9ca478 to 81b7fd1 Compare February 13, 2026 02:46
@wschurman wschurman force-pushed the wschurman/02-12-feat_add_pagination_max_page_size_configuration branch from 81b7fd1 to c75676d Compare February 13, 2026 03:35
@wschurman wschurman marked this pull request as ready for review February 13, 2026 03:38
@wschurman wschurman requested a review from quinlanj February 13, 2026 03:38
@wschurman wschurman force-pushed the wschurman/02-09-feat_add_ilike_and_trigram_similarity_search_to_pagination branch from 28b5ab9 to 89f4ba6 Compare February 16, 2026 00:06
@wschurman wschurman force-pushed the wschurman/02-12-feat_add_pagination_max_page_size_configuration branch from c75676d to 105989b Compare February 16, 2026 00:06
@wschurman wschurman requested a review from ide February 16, 2026 18:01
Copy link
Member Author

wschurman commented Feb 16, 2026

Merge activity

  • Feb 16, 8:58 PM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Feb 16, 8:59 PM UTC: Graphite rebased this pull request as part of a merge.
  • Feb 16, 9:02 PM UTC: @wschurman merged this pull request with Graphite.

@wschurman wschurman changed the base branch from wschurman/02-09-feat_add_ilike_and_trigram_similarity_search_to_pagination to graphite-base/436 February 16, 2026 20:58
@wschurman wschurman changed the base branch from graphite-base/436 to main February 16, 2026 20:58
@wschurman wschurman force-pushed the wschurman/02-12-feat_add_pagination_max_page_size_configuration branch from 105989b to b4c15d5 Compare February 16, 2026 20:59
@wschurman wschurman merged commit 3ec4b5f into main Feb 16, 2026
3 checks passed
@wschurman wschurman deleted the wschurman/02-12-feat_add_pagination_max_page_size_configuration branch February 16, 2026 21:02
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.

2 participants

Comments