Skip to content

fix: bound FULL task pages by size in bytes - #458

Merged
uniqueg merged 5 commits into
devfrom
fix/full-page-bytes
Nov 7, 2026
Merged

uniqueg merged 5 commits into
devfrom
fix/full-page-bytes

Conversation

@uniqueg

@uniqueg uniqueg commented Nov 7, 2026 •

Copy link
Copy Markdown
Member

Summary

Pages of GET /tasks?view=FULL are now also bounded by size, the last open item of #416:

  • New setting custom.controllers.list_tasks.max_page_bytes_full (default 10485760, i.e., 10 MiB), next to max_page_size_full.
  • A page ends before the task that would take its tasks past the bound; its next_page_token continues after the last task served, so paging returns every task once.
  • A page always has at least one task, however large.
  • max_page_size_full still applies; other views are unchanged.
  • Tasks are counted with their size in the response body: connexion serves indented JSON (2 spaces, ASCII), so a task in a page takes more than its compact JSON. served_size() counts the indented JSON plus the extra indentation of the nesting, and a test checks it against the real body.
  • Tasks of the view FULL are fetched one at a time (batch_size(1)), so the driver decodes no task beyond the end of a page.

Closes #455

Docs

  • docs/configuration.md (Tasks): the new setting, and memory per request (about 3 times the bound plus one task for large texts, up to about 7 times for many small fields).
  • docs/api.md: GET /tasks mentions the bound.
  • docs/upgrading.md (To version 0.6.0): pages with large tasks hold fewer tasks; paging clients are unaffected.
  • deployment/values.yaml and deployment/README.md: the setting next to max_page_size_full and the memory limit.
  • pro_tes/config.yaml: the setting and its comment.

Verification

  • Test first: test_list_tasks_page_bytes_full and test_list_tasks_page_bytes_one_task failed before the bound; test_list_tasks_served_size and test_list_tasks_full_batches failed before the review fix.

  • coverage run -m pytest (mongomock; chart tests with helm): 1750 passed, 11 skipped; coverage report 100%.

  • Against MongoDB 7.0 locally (MONGODB_TEST_URI): tests/ga4gh/tes/test_server.py 166 passed.

  • ruff check / ruff format --check (0.17.3), mypy, ast-grep scan, semgrep --config=.semgrep: clean. mkdocs build --strict: OK.

  • Review: adversarial-reviewer and quality-reviewer. Fixed:

    • the size measured as compact JSON while the body is indented (up to about 3.4 times larger);
    • whole driver batches decoded beyond the cut;
    • wording of the docs on memory, and a comment on the token.
  • Review round 2 (adversarial-reviewer): one low, fixed: the memory per request is an estimate, not a bound (up to about 7 times the response size for tasks with many small fields); the docs now say so.

  • Sourcery: memory with 4 threads and the default could exceed the chart's 256 MiB; fixed by setting max_page_bytes_full to 4 MiB in the chart (tests/test_chart.py), with the estimate in values.yaml, deployment/README.md, Configuration and the upgrade notes. Chart, config example and README tests: 284 passed.

  • CI: all checks passed (CI passed).

Declined review findings

None.

Open questions

None.

🤖 Generated with Claude Code

Summary by Sourcery

Limit FULL task-list pages by response size as well as task count without changing other views or pagination completeness.

New Features:

  • Bound FULL task-list pages by both task count and response-body size, while preserving complete token-based pagination and at least one task per page.

Enhancements:

  • Fetch FULL tasks incrementally and size pages according to their actual indented JSON representation.
  • Document the new page-size setting, memory considerations, API behavior, upgrade impact, and deployment defaults.

Deployment:

  • Set the Helm chart default for max_page_bytes_full to 4 MiB to keep FULL pages within the chart memory limit.

Documentation:

  • Document the new configuration option and its effects on API pagination, upgrades, and deployment memory sizing.

Tests:

  • Add coverage for response-size accounting, byte-bounded pagination, oversized single-task pages, and incremental FULL-view fetching.

uniqueg and others added 3 commits November 7, 2026 15:49
Pages of `GET /tasks?view=FULL` now also end before their tasks exceed
`custom.controllers.list_tasks.max_page_bytes_full` bytes of JSON
(default 10 MiB), besides `max_page_size_full` tasks. A page always
has at least one task, and its `next_page_token` continues after the
last task served. Document the setting, its memory bound, the chart's
notes and the upgrade note.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Responses are indented JSON (connexion indents by 2 spaces), so a task
takes up to several times its compact size in the body. Count each task
with its size in the body, and fetch tasks of the view FULL one at a
time, so that the driver decodes no task beyond the end of a page.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The bound counts the response body; decoded tasks with many small
fields take up to about 7 times its size in memory.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@uniqueg uniqueg added this to the v0.6.0 milestone Nov 7, 2026
@sourcery-ai

sourcery-ai Bot commented Nov 7, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

Data structures

Add the positive max_page_bytes_full setting to the ListTasks configuration model so page-size enforcement has a defined, validated input.

  • pro_tes/config_models.py L174-176, L185-186, L194-195

Implementation

Measure FULL tasks as they appear in the indented response and stop before exceeding the byte limit while preserving paging and fetching one task at a time.

  • pro_tes/ga4gh/tes/task_runs.py L266-282, L893-902, L912-920 (+2 small edits)

Configuration

Set the new byte limit in the application defaults and Helm chart, and explain the chart’s memory sizing alongside its existing task-count limit.

  • deployment/values.yaml L41, L47, L337-344
  • pro_tes/config.yaml L298-300, L305
  • tests/test_chart.py L364-369

Documentation

Document the new FULL-page byte limit, its paging behavior, memory implications, deployment guidance, and upgrade impact.

  • deployment/README.md L31-34
  • docs/api.md L16
  • docs/configuration.md L572-574, L582-595
  • docs/upgrading.md L139-149

Tests

Verify served-size accounting, one-at-a-time FULL fetching, byte- and count-limited paging, the minimum-one-task behavior, and configuration validation.

  • tests/ga4gh/tes/test_server.py L707-811, L817-819

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@read-the-docs-community

read-the-docs-community Bot commented Nov 7, 2026 •

Copy link
Copy Markdown

Documentation build overview

📚 proTES | 🛠️ Build #35721647 | 📁 Comparing 028717d against latest (53ce92b)

  🔍 Preview build  

6 files changed · ± 6 modified

± Modified

@codecov

codecov Bot commented Nov 7, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (48d1965) to head (028717d).
⚠️ Report is 1 commits behind head on dev.

Additional details and impacted files
@@            Coverage Diff            @@
##               dev      #458   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           31        31           
  Lines         2998      3013   +15     
=========================================
+ Hits          2998      3013   +15     

☔ View full report in Codecov by Harness.
📢 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.

@uniqueg
uniqueg marked this pull request as ready for review November 7, 2026 16:01

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="pro_tes/config_models.py" line_range="194" />
<code_context>
     # full tasks may be large (e.g., with inline contents of inputs)
     max_page_size_full: PositiveInt = 64
+    # full tasks may be large also in few numbers (e.g., with long logs)
+    max_page_bytes_full: PositiveInt = 10485760

     @model_validator(mode="after")
</code_context>
<issue_to_address>
**FULL pages can exhaust memory**

When a deployment uses those defaults and concurrent FULL pages contain enough many-small-field tasks to approach the byte cap, `served_size` serializes each decoded task while the page retains its task dictionaries; for many-small-field tasks, the documented memory estimate reaches about seven times the 10 MiB default. Four concurrent requests can therefore exceed the chart’s 256 MiB limit and restart the app, disrupting requests.

Lower the default or chart byte limit, or otherwise ensure the configured cap and concurrency fit the app’s memory limit.

Also at `pro_tes/ga4gh/tes/task_runs.py:278`.
</issue_to_address>

Linked issues

#455 fix: bound FULL task pages by size in bytes · 4 of 4 met

# Requirement Status Notes
1 Bound FULL pages by configurable max_page_bytes_full, default 10 MiB ✅ Met The setting defaults to 10485760 bytes and the listing code counts each FULL task against the response-body size.
2 Always include at least one task and continue next_page_token after the last returned task ✅ Met The byte limit is enforced only after a task has been added, and the token is set to the ID of the last task served when the next task would exceed the limit.
3 Keep max_page_size_full in effect ✅ Met FULL page sizes remain capped by max_page_size_full; the byte limit is applied in addition to that cap.
4 Add unit and integration tests, document the setting and chart memory notes, and include upgrade notes ✅ Met The change adds configuration and API tests, documents the setting and memory estimates, updates the chart notes, and adds an upgrade note.

Sourcery assessment

Approval pending. 1 finding to address first.

Blocking findings: pro_tes/config_models.py:194


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread pro_tes/config_models.py Resolved
uniqueg and others added 2 commits November 7, 2026 17:22
With the app default of 10 MiB, pages of tasks with many small fields
take up to about 70 MiB per request, so 4 threads could exceed the
chart's memory limit of 256 MiB. Set 4 MiB in the chart, next to
max_page_size_full, and give the memory estimate in values.yaml.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@uniqueg
uniqueg merged commit c7fcfff into dev Nov 7, 2026
34 checks passed
@uniqueg
uniqueg deleted the fix/full-page-bytes branch November 7, 2026 16:57
@uniqueg uniqueg mentioned this pull request Nov 7, 2026
6 tasks done
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.

fix: bound FULL task pages by size in bytes

1 participant