Repository navigation
#476 Fix result limits across OCI MCP tools #489
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
75cfbb3
34a0a93
cf71cad
55ab267
13977ef
494c1a1
8273aaf
4af4fdf
89077c3
8ff6e25
1150593
28edccd
027bb56
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -133,10 +133,11 @@ def list_instances( | |
| next_page: str = None | ||
|
|
||
| while has_next_page and (limit is None or len(instances) < limit): | ||
| remaining = None if limit is None else limit - len(instances) | ||
| kwargs = { | ||
| "compartment_id": compartment_id, | ||
| "page": next_page, | ||
| "limit": limit, | ||
| "limit": remaining, | ||
| } | ||
|
|
||
| if lifecycle_state: | ||
|
|
@@ -149,8 +150,10 @@ def list_instances( | |
| data: list[oci.core.models.Instance] = response.data | ||
| for d in data: | ||
| instance = map_instance(d) | ||
| instances.append(instance) | ||
|
|
||
| if limit is None or len(instances) < limit: | ||
| instances.append(instance) | ||
| else: | ||
| break | ||
| logger.info(f"Found {len(instances)} Instances") | ||
| return instances | ||
|
|
||
|
|
@@ -341,10 +344,11 @@ def list_images( | |
| next_page: str = None | ||
|
|
||
| while has_next_page and (limit is None or len(images) < limit): | ||
| remaining = None if limit is None else limit - len(images) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Comment from @dustin-sale via Codex. [P2] Commit regressions for the pagination boundaries Evidence: the PR changes 18 loops but changes tests only in Identity. Compute's tool tests contain no limit assertions. Supplemental review probes reproduce the original five-results-for-limit=3 behavior on the base revision and pass on this head, including filtered-image pagination. Impact: high line coverage currently allows the original total-cap defect to pass undetected, leaving these fixes vulnerable to regression. Requested change: add package-local regression coverage for the affected tools using short pages followed by continuation, empty pages with continuation, remaining request allowances, exact-cap stopping, and unlimited traversal. Include a filtered-out image page followed by matching images and verify the emitted match cap. The regressions should fail on the original implementation. |
||
| kwargs = { | ||
| "compartment_id": compartment_id, | ||
| "page": next_page, | ||
| "limit": limit, | ||
| "limit": remaining, | ||
| } | ||
|
|
||
| response = client.list_images(**kwargs) | ||
|
|
@@ -357,7 +361,10 @@ def list_images( | |
|
|
||
| for d in data: | ||
| image = map_image(d) | ||
| images.append(image) | ||
| if limit is None or len(images) < limit: | ||
| images.append(image) | ||
| else: | ||
| break | ||
|
|
||
| logger.info(f"Found {len(images)} Images") | ||
| return images | ||
|
|
@@ -434,10 +441,11 @@ def list_vnic_attachments( | |
| next_page: str = None | ||
|
|
||
| while has_next_page and (limit is None or len(vnic_attachments) < limit): | ||
| remaining = None if limit is None else limit - len(vnic_attachments) | ||
| kwargs = { | ||
| "compartment_id": compartment_id, | ||
| "page": next_page, | ||
| "limit": limit, | ||
| "limit": remaining, | ||
| } | ||
|
|
||
| if instance_id: | ||
|
|
@@ -450,8 +458,10 @@ def list_vnic_attachments( | |
| data: list[oci.core.models.VnicAttachment] = response.data | ||
|
|
||
| for d in data: | ||
| vnic_attachments.append(map_vnic_attachment(d)) | ||
|
|
||
| if limit is None or len(vnic_attachments) < limit: | ||
| vnic_attachments.append(map_vnic_attachment(d)) | ||
| else: | ||
| break | ||
| logger.info(f"Found {len(vnic_attachments)} Vnic Attachments") | ||
| return vnic_attachments | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.