Skip to content

fix: add max_items limit to fetch_all_edges to prevent unbounded memory growth#515

Open
harshitanand wants to merge 1 commit into666ghj:mainfrom
harshitanand:fix/issue-513-fetch-all-edges-max-items
Open

fix: add max_items limit to fetch_all_edges to prevent unbounded memory growth#515
harshitanand wants to merge 1 commit into666ghj:mainfrom
harshitanand:fix/issue-513-fetch-all-edges-max-items

Conversation

@harshitanand
Copy link
Copy Markdown

What

fetch_all_nodes has a max_items guard (default 2000) to cap memory usage during pagination, but fetch_all_edges had no equivalent safeguard — allowing unbounded memory growth on graphs with large numbers of edges.

How

  • Added _MAX_EDGES = 5000 constant alongside the existing _MAX_NODES = 2000
  • Added max_items: int = _MAX_EDGES parameter to fetch_all_edges signature
  • Added the same loop-guard pattern used in fetch_all_nodes: cap the list, emit a logger.warning, and break pagination once the limit is reached
  • Updated the docstring to document the new default cap

The change is a direct mirror of the existing fetch_all_nodes implementation — no new patterns introduced.

Testing

  • Diff verified against fetch_all_nodes pattern — identical guard logic
  • No existing tests broken (no test suite for this module currently)
  • Backwards compatible — max_items is an optional parameter with a sensible default

Related

Closes #513

…ry growth (666ghj#513)

fetch_all_nodes already had a max_items guard (default 2000) but
fetch_all_edges had no such safeguard, allowing unbounded memory growth
on graphs with large numbers of edges.

Add _MAX_EDGES = 5000 constant and mirror the same loop-guard pattern
from fetch_all_nodes: cap the result list, emit a warning log, and
break pagination once the limit is reached.
@dosubot dosubot bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label Apr 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: add max_items limit to fetch_all_edges to prevent unbounded memory growth

1 participant