Skip to content

_list() pagination issue for smaller page size #102

Description

@isivaselvan

python-tfe version

0.1.2

Description

_list pagination in _base.py can repeatedly request page 1 and appear to hang (or loop indefinitely) when callers pass page[number] in params and use smaller page[size].

The current logic uses setdefault("page[number]", page) inside the loop.
When params already contains page[number] (for example from RunListOptions), setdefault does not overwrite it, so the request stays pinned to the same page even though page += 1 executes.

This is visible in examples/run.py when listing runs with smaller page sizes.

Testing plan

1. Export valid TFE credentials:
   - TFE_TOKEN
   - (optional) TFE_ADDRESS, TFE_ORG
2. Run:
   python examples/run.py --workspace-id=<workspace_id> --page-size=20
   -> completes.
3. Run:
   python examples/run.py --workspace-id=<workspace_id> --page-size=5
   -> repeatedly processes the same page and appears stuck.
4. Instrument request params/logs and observe:
   page[number] remains 1 across repeated requests.

Expected Behavior

Pagination should advance page-by-page (page[number]=1,2,3,...) and terminate normally when no more data is available.

Actual Behavior

For smaller page sizes, the same page is repeatedly requested, causing an apparent infinite loop / very long-running list call.

Additional Context

  • Behavior depends on page size and number of records,
  • larger page[size] may hide the bug,
  • smaller page[size] makes it obvious.
  • Likely fix: overwrite page[number] each loop iteration instead of using setdefault.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions