Skip to content

feat(sdk): paginate list_applications - #1152

Draft
hanchchch wants to merge 1 commit into
mainfrom
hanch/vul-1330-sdk-pagination
Draft

feat(sdk): paginate list_applications#1152
hanchchch wants to merge 1 commit into
mainfrom
hanch/vul-1330-sdk-pagination

Conversation

@hanchchch

Copy link
Copy Markdown
Collaborator

Draft — blocked on #1151. Depends on isolate_proto >= 0.34.3. CI will be red until that is released and the pin here is bumped; I'll push the pin bump as soon as the tag exists.

Why

ListApplications returns one entry per application revision, and one production account currently has 547k of them. With no pagination and grpc.max_send_message_length = -1 on the server, a single call hydrates and serialises an unbounded result set — which OOM-killed the isolate-cloud grpc pods on 2026-08-21 (VUL-1330 / INFRA-4247).

#1151 adds the wire fields. This PR makes the SDK use them.

What

FalServerlessConnection.list_applications now follows next_page_token until it is unset.

  • Backward compatible. The return type is still list[ApplicationInfo] containing every revision, so fal apps revisions (the only caller) is unchanged.
  • page_size is optional and only tunes the request size — the server applies its own default and ceiling, so omitting it is safe.

Two subtleties the tests pin down:

  1. A short page is not the last page. Only an absent next_page_token ends the walk; the server may return fewer rows than page_size and still have more.
  2. A repeated cursor terminates the loop. If the server ever hands back the same token twice, a server-side bug would otherwise become an infinite loop in every client.

Testing

Validated against the new proto by installing #1151's isolate_proto from a worktree:

  • pytest projects/fal/tests/unit/test_sdk.py28 passed (3 new)
  • pre-commit run --files projects/fal/src/fal/sdk.py projects/fal/tests/unit/test_sdk.py — ruff-format, ruff and the rest pass. mypy failed locally only, on a hook-environment problem (typed_ast not installed), not a type error; CI runs it in a proper env.

Sequence

  1. feat(proto): add pagination to ListApplications #1151 → merge + release isolate_proto_v0.34.3
  2. this PR → bump the isolate_proto pin, un-draft
  3. isolate-cloud → honour page_size/page_token server-side, with a default and ceiling that also bound old clients

🤖 Generated with Claude Code

ListApplications is getting page_size/page_token/next_page_token so the
server can stop hydrating and serialising an unbounded number of
application revisions (VUL-1330 -- this OOM-killed the isolate-cloud grpc
pods on 2026-08-21).

list_applications now walks next_page_token until it is unset, so callers
keep the previous "everything" semantics and `fal apps revisions` keeps
working unchanged. page_size is optional and only tunes the request size;
the server applies its own default and ceiling.

Two subtleties the tests pin down: a short page is not the last page (only
an absent token is), and a server that keeps returning the same cursor must
not spin the client forever.

Requires isolate_proto >= 0.34.3; the pin bump follows once that is released.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@linear-code

linear-code Bot commented Aug 21, 2026

Copy link
Copy Markdown

VUL-1330

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.

1 participant