Repository navigation
Conversation
…ot 500 The Omi backend forwards `geolocation` to this app as free-form JSON, and the field is typed `dict[str, Any]`, so pydantic does not coerce the values inside it. A coordinate that arrives as a list or an object therefore reached `float()` in `_normalize_float`, which raises TypeError. `call_uber` only handles ValueError, so the request failed with an unhandled 500 instead of the 400 the app already documents for a bad geolocation (`test_main.test_bad_geolocation_returns_400` covers only the string case). `_normalize_float` now converts that TypeError into a ValueError naming the offending type, which is the contract `call_uber` already maps to a 400. Adds `test_geolocation_types.py`: five stdlib-only tests pin the ValueError contract and the accepted inputs, and two skip-if-absent TestClient tests assert the endpoint returns 400 for list/dict/tuple coordinates and still builds links for a valid geolocation. Registered in the checks manifest so CI runs it. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
Keeping this open on 11077c0. Uber link parsing on main still returns float(value) with no guard. This head turns TypeError into ValueError, and the tests import build_location. The only check is cubic, so this is not an approval. Not approving this SHA. — Astar, on behalf of @aryanorastar |
|
Verified the bug and the fix against this head. plugins/uber_call/uber_links.py — the try/except TypeError -> ValueError in _normalize_float is the right shape and the right place: it is the single choke point both pickup and dropoff coordinates pass through, so build_location now always raises the ValueError that call_uber maps to 400. The message names the offending type and chains the original exception (raise ... from exc). Diffed against main — this is the only semantic change in the module. The root cause checks out: main.py types geolocation as dict[str, Any], _geo_value only filters None/"", and call_uber catches ValueError only (plugins/uber_call/main.py:142), so a list/object coordinate previously escaped as TypeError -> 500. The existing test_bad_geolocation_returns_400 covered only the string case, which is exactly the gap claimed. plugins/uber_call/test_geolocation_types.py — good coverage: unit tests assert ValueError with the type name for list/dict/tuple on both latitude and longitude, pin no-behavior-change for numeric strings/empty/None, and the endpoint tests use TestClient(app, raise_server_exceptions=False), which is the correct way to assert "400, never an unhandled 500". The skipIf guard keeps it runnable where fastapi/httpx are absent. Ran the suite locally on this head: 7/7 pass, including both endpoint tests. .github/checks-manifest.yaml — the uber-call-geolocation-type-tests entry is well-formed and matches the manifest's existing shape (command, triggers on plugins/uber_call/** and the manifest itself, both lanes). One non-blocking follow-up, same class of bug on the sibling path: a non-scalar geolocation.formatted_address (e.g. ["123 Main St"]) reaches _clean_text, where value.split() raises AttributeError and still returns a 500 on this head — verified via TestClient. No need to widen this PR; worth a follow-up issue or small change covering the address fields the same way. Nice first contribution — clean scope, precise PR description, and the tests pin the contract properly. Leaving for human maintainer merge. 🤖 Automated review on behalf of the maintainers. by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with |
kodjima33
left a comment
There was a problem hiding this comment.
Verified real bug reproduced against current main (root cause confirmed by direct source inspection), scoped diff, regression tests added and shown to fail on unpatched code. Confidence 5/5 — merging.
What changed and why
POST /api/call_uberreturned HTTP 500 when ageolocationcoordinate arrived as a list or an object; it now returns the 400 the app already documents for a bad geolocation.The backend forwards
geolocationas free-form JSON and the field is typeddict[str, Any], so pydantic does not coerce the values inside it — unlike the top-levelpickup_latitude/dropoff_latitudefloats, which pydantic rejects with a 422. A non-scalar value therefore reachedfloat()inuber_links._normalize_float, which raisesTypeError, whilecall_uberonly catchesValueError— so it escaped as an unhandled 500.test_main.test_bad_geolocation_returns_400pins this contract for the string case only, which is why the gap survived.The fix converts that
TypeErrorinto aValueErrornaming the offending type, at the single helper every coordinate is normalised through. No behaviour change for numbers, numeric strings,None, or"".Product invariants affected
none
How it was verified
Reproduced against the real endpoint on
mainbefore the fix, viaTestClient(app, raise_server_exceptions=False):After the fix the same three requests return 400/400/400, and a valid
{"latitude":37.7749,"longitude":-122.4194}still returns 200 with anm.uber.comlink.make preflight— passed, 15 checks, withuber-call-geolocation-type-testsselected.scripts/pr-preflight --pr-body-filewith this body — passed, 15 checks.test_coord_bounds.py3/3,test_uber_links.py4/4,test_main.py2/2.Tests
New
plugins/uber_call/test_geolocation_types.py— the regression test that would have caught this bug:ValueErrorcontract for list/dict/tuple latitude and longitude, and that numeric strings, numbers,""andNonebehave exactly as before.skipIf(TestClient is None)tests drive the real endpoint for the 400 and the 200 path, matching the existingtest_main.pyharness style.CI has no plugin dependencies installed, so I checked the suite with
fastapi,httpx,pydanticandstarlettemade unimportable through aMetaPathFinder: 5 run / 2 skipped / 0 failures. The defect contract stays pinned in CI rather than silently skipping in full.Failure class (fixes)
Failure-Class: FC-chat-tool-input-assumed-typed-and-complete
Loosely-typed, human-shaped chat-tool input crashing a handler with
TypeErrorinstead of returning a clean tool error is squarely this class's violated contract. The fix follows its canonical prevention: validate in one shared normalisation helper, pinned by a manifest-registered hermetic suite that drives the real handler through dirty inputs.New guards (only when adding a check or ratchet)
uber-call-geolocation-type-testsis the manifest entry for the suite above. The incident it would have caught is this one:plugins/uber_callhas no checks-manifest entry today, so none of its three existing suites run in CI, and the 500 was reachable from an ordinary chat-tool call.It is not a shared primitive because the coercion is per-app: each plugin reads
geolocationwith its own helper and its own accepted key spellings (latitude/lat,longitude/lng/lonhere), so the guard has to drive this app's normaliser. The registered class-level prevention for the shared half already exists as FC-chat-tool-input-assumed-typed-and-complete's canonical artifact.Scoped cleanups (optional)
None included. One adjacent gap I deliberately left out, happy to take it if you would rather:
plugins/uber_call's three pre-existing suites (test_coord_bounds,test_uber_links,test_main) also have no checks-manifest entries, so they still will not run in CI after this PR. I registered only the new suite to keep this scoped — say the word and I will add the other three.🤖 Generated with Claude Code