fix: add max_items limit to fetch_all_edges to prevent unbounded memory growth#515
Open
harshitanand wants to merge 1 commit into666ghj:mainfrom
Open
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
fetch_all_nodeshas amax_itemsguard (default 2000) to cap memory usage during pagination, butfetch_all_edgeshad no equivalent safeguard — allowing unbounded memory growth on graphs with large numbers of edges.How
_MAX_EDGES = 5000constant alongside the existing_MAX_NODES = 2000max_items: int = _MAX_EDGESparameter tofetch_all_edgessignaturefetch_all_nodes: cap the list, emit alogger.warning, and break pagination once the limit is reachedThe change is a direct mirror of the existing
fetch_all_nodesimplementation — no new patterns introduced.Testing
fetch_all_nodespattern — identical guard logicmax_itemsis an optional parameter with a sensible defaultRelated
Closes #513