[Bounty proposal] fix(shopify-app): get_orders and get_customers crash with TypeError on the JSON null the backend sends for omitted limit
Symptom
The Shopify app's two listing tools fail on an ordinary request. "Show my recent orders" and "who are my customers?" / "find customer Ada" come back as:
Failed to get orders: '<' not supported between instances of 'int' and 'NoneType'
Failed to get customers: '<' not supported between instances of 'int' and 'NoneType'
The user does not have to mention a result count for this to happen.
Evidence
plugins/omi-shopify-app/main.py, tool_get_orders and tool_get_customers, both:
limit = min(body.get("limit", 10), 50)
body.get("limit", 10) only falls back to 10 when the key is absent, and the Omi backend never omits it. backend/utils/retrieval/tools/app_tools.py::_create_pydantic_model_from_schema turns every non-required manifest parameter into Optional[int] with Field(default=None), and _call_tool_endpoint forwards the model's kwargs verbatim as the JSON body. With the backend's pinned langchain-core==1.3.3, a StructuredTool built from that schema passes the defaulted fields through even when the LLM did not supply them:
# langchain-core 1.3.3, args_schema = create_model(limit=(Optional[int], None))
{} -> {'limit': None}
{'limit': None} -> {'limit': None}
{'limit': '5'} -> {'limit': 5}
So both handlers receive {"uid": ..., "limit": null, ...}, min(None, 50) raises TypeError, and the blanket except turns it into the strings above. get_analytics, get_order_details, create_order and create_customer are unaffected (no optional integer input).
Secondary: ints that do arrive are capped from above only, so limit: 0 or a negative value is sent to Shopify as the limit query parameter, which the Admin REST API rejects (it accepts 1..250).
Running both handlers in a hermetic harness against main reproduces it (see the regression test below):
$ python3 test_limit_inputs.py # with main.py from origin/main
tool_get_orders: Failed to get orders: '<' not supported between instances of 'int' and 'NoneType'
tool_get_customers: Failed to get customers: '<' not supported between instances of 'int' and 'NoneType'
tool_get_orders: Failed to get orders: '<' not supported between instances of 'int' and 'str'
AssertionError: -3 != 1 (negative limit forwarded)
FAILED (failures=19)
Same defect class as #13931 (Whoop), #13937 (Google Calendar) and #13944 (Notion); this is the Shopify instance.
Fix
Add one boundary helper in plugins/omi-shopify-app/main.py:
def _coerce_int(value, default, minimum, maximum) -> int
that maps None/booleans/unparseable/overflowing values to the default, accepts ints and numeric strings, and clamps into [minimum, maximum], and use it at both sites:
limit = _coerce_int(body.get("limit"), default=10, minimum=1, maximum=50)
The manifest's documented default and cap ("default: 10, max: 50") are unchanged; they are now enforced instead of assumed.
Tests
New hermetic suite plugins/omi-shopify-app/test_limit_inputs.py (stdlib-only, same double pattern as the existing test_create_order_pagination.py; no network) executes tool_get_orders, tool_get_customers (listing) and tool_get_customers (search) through the requests.get seam and asserts:
limit: nullproduceslimit=10on/orders.json,/customers.jsonand/customers/search.json, with a rendered result (fails onmainwith the TypeError above);- numeric strings are coerced;
0/negative values are clamped to 1; oversized values are capped at 50; unparseable and overflowing (1e309→inf) values fall back to 10.
Registered as shopify-app-limit-input-tests in .github/checks-manifest.yaml (local + ci lanes).
Proposed Bounty Reward: $50.00 USD Bounty Payout Destination (PayPal): will be provided by email to [email protected] on payout
cc @josancamon19 @kodjima33
I implemented the requested fix in PR #13956: https://github.com/BasedHardware/omi/pull/13956
It normalizes optional Shopify limit values (including JSON null, booleans, malformed/non-integral values, and numeric strings) and clamps valid values to 1–50 for both get_orders and get_customers. I verified the handlers locally across those edge cases; the existing Shopify pagination tests pass 9/9.
I’m claiming the proposed $50 bounty. Reward and payment remain subject to maintainer review and the bounty terms.
Same root cause as #13974 — _create_pydantic_model_from_schema types non-required params as Optional[...] with default None, and the backend forwards them as null to the app. Fix: add _drop_none() helper in app_tools.py to strip None-valued kwargs before forwarding. Also fix the 2 Shopify handlers to use a _coerce_int boundary helper (see #13946 description for the exact fix).
I have implemented a clean, hermetic fix with complete unit test coverage in PR #14172.
Summary of Changes
- Safely coerces
raw_limit = body.get("limit")to positive integers clamped between[1, 50], falling back cleanly to default10whenNone, omitted, or non-integer. - Fixed both
tool_get_ordersandtool_get_customers. - Added hermetic regression test suite
plugins/omi-shopify-app/test_list_limits.py(6 unit tests verifying all null/edge-case conditions). All 22 tests across the shopify plugin pass cleanly.
PR: https://github.com/BasedHardware/omi/pull/14172
Payout Address (USDC Base/Polygon): 0xa709768e0B597df11b2B81AB7ea54EEacd2532D0
Resolved in PR #14292:
_coerce_intCoercion & Clamping: Safely parsesNone(falling back to default 10), booleans (avoidingint(True) == 1pitfall), numeric strings, and out-of-range numbers into clamped integer bounds[1, 50].- Defensive Body Guards: Guarded all chat tool endpoints against
Noneor non-dict payloads. - Hermetic Test Suite: Added 23 isolated unit tests in
test_limit_inputs.pyrunning under barepython3 -Sin 0.09s with zero external dependencies. - Checks Manifest: Registered
shopify-app-limit-input-testsin.github/checks-manifest.yaml.
Closing as already fixed on current main.
Merged #14292; current main get_orders/get_customers use _coerce_int(limit) + test_limit_inputs.py in CI