Skip to content

fix(plugins): follow ShipBob pagination in name matching and search - #14427

Merged
kodjima33 merged 1 commit into
BasedHardware:mainfrom
hridaya423:fix/shipbob-pagination
Sep 18, 2026
Merged

kodjima33 merged 1 commit into
BasedHardware:mainfrom
hridaya423:fix/shipbob-pagination

Conversation

@hridaya423

@hridaya423 hridaya423 commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #14426

Summary

get_products/get_inventory in plugins/omi-shipbob-app/main.py return a single Page/Limit page, but three call sites treated page 1 as the complete catalog:

  • find_product_candidates/find_inventory_candidates advertised "all hits" while reading only the first 100 records; anything later reported Could not find ....
  • /tools/get_products?search= filtered page 1 client-side, so a matching product past the first 100 returned No products found.
  • tool_create_wro's inventory-id fallback scanned page 1 only, so WRO creation could fail with Could not find inventory ID for a valid product.

The fix adds _fetch_all_pages, which drains Page/Limit pages until a short page (or a 25-page / 2,500-item safety cap), and wires it into every completeness-sensitive path. Bounded listing calls (limit provided by the caller) still read one page.

Same failure class as the daily-memory-sweep fix: FC-single-page-cap-mistaken-for-complete-proof. A completeness check implemented as a single bounded page silently fails for accounts bigger than one page.

Tests

python3 -m pytest plugins/omi-shipbob-app/test_main.py -x -q: 66 passed (61 existing + 5 new pagination regressions):

  • multi-page aggregation (100+100+37 → 237 items)
  • early termination on a short page
  • safety cap honored (25 pages max)
  • find_product_candidates resolves a name living on page 2
  • /tools/get_products?search= finds a product past page 1

Also ran the diff-scoped manifest checks directly: runtime_image_contracts.py check (15 images pass) and plugins/oauth/test_client_log_safety.py (5/5). Local make preflight fails at workflow-apt-network-bounds only because its script builds backend/.venv and the webrtcvad wheel can't compile on this machine's toolchain; unrelated to this diff (triggers are .github/workflows/**).

Hermetic tests only; no live ShipBob calls in CI.

Failure-Class: FC-single-page-cap-mistaken-for-complete-proof

get_products/get_inventory return a single Page/Limit page, but
find_product_candidates, find_inventory_candidates, the WRO
inventory-id fallback, and the /tools/get_products search filter all
matched or filtered as if the first page were the complete catalog.
Products or inventory records beyond page 1 reported 'not found', so a
chat request could fail or a WRO could be created against the wrong
item.

Add _fetch_all_pages to drain bounded pages (with a 25-page safety cap)
and use it on every completeness-sensitive path.

Verification: python3 -m pytest test_main.py -x -q (66 passed,
including 5 new pagination regressions covering multi-page
aggregation, short-page termination, the page cap, and a page-2 name
match).

Failure-Class: FC-single-page-cap-mistaken-for-complete-proof
@Git-on-my-level

Copy link
Copy Markdown
Member

Verified end to end in a sandboxed container (plugin files at the PR head, network disabled, ShipBob calls mocked): the full plugin suite passes 66/66, and each claim in the description reproduces independently.

plugins/omi-shipbob-app/main.py

  • _fetch_all_pages is correct: pages of 100 are drained until a short page, with a 25-page / 2,500-item cap. Because get_products/get_inventory return [] for both an empty page and an API-error dict ({"error": ...}), an erroring page reads as a short page and stops the loop — no infinite-loop risk on API errors.
  • All three completeness-sensitive call sites are converted: find_product_candidates / find_inventory_candidates, the search branch of tool_get_products, and the tool_create_wro inventory-id fallback. Bounded callers are untouched — tool_get_inventory and the non-search branch of tool_get_products still fetch a single caller-sized page (observed exactly one request, Page=1 Limit=10 for limit=10).
  • The WRO fallback now resolves inventory ids past page 1: in a mock run the posted WRO carried inventory_id 77 from page 2, which was invisible before this change.

plugins/omi-shipbob-app/test_main.py

  • TestPagination pins the right contract: aggregation (100+100+37 → 237), early stop on a short page, the 25-page cap, name matching past page 1, and the search path. The _pages helper asserts the exact page sequence requested, so regressions to single-page reads fail loudly.

Two non-blocking notes for a possible follow-up:

  • A name lookup on a large catalog can now issue up to 25 sequential ShipBob requests per tool call. The cap keeps this bounded, but a log line when the cap is reached would make silent truncation at 2,500 items much easier to diagnose.
  • _fetch_all_pages is endpoint-generic; if another list endpoint grows name matching later, reuse it rather than adding a copy.

Clean fix with strong regression coverage — thanks. Leaving the formal approval and merge decision to a human maintainer; no security, privacy, or product-direction concerns found in this diff.


by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.

@Git-on-my-level Git-on-my-level added positive-signal Automation verified a genuine fix/quality contribution python labels Sep 18, 2026
@hridaya423

Copy link
Copy Markdown
Contributor Author

Thanks for the sandbox verification! Both notes make sense — happy to add a log line when _fetch_all_pages hits the 25-page cap in a follow-up if you'd like it.

@kodjima33 kodjima33 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed page-1-only bug still on main across find_product_candidates/find_inventory_candidates/tool_get_products search/tool_create_wro fallback. _fetch_all_pages fix is scoped, capped, well-tested (5 new pagination regressions), CI green. Author hridaya423 flagged for twin-account campaign scrutiny (0/17 merged) but this diff is clean on the merits. 4/5.

@kodjima33
kodjima33 merged commit e763584 into BasedHardware:main Sep 18, 2026
43 of 71 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

positive-signal Automation verified a genuine fix/quality contribution python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bounty] fix(shipbob-app): name matching and search read only page 1 of products/inventory

3 participants