Skip to content

fix(uber createDelivery): send the 4 required pickup/dropoff contact fields (no more invalid_params)#495

Merged
alexpmichelet merged 2 commits into
mainfrom
agent/uber-createdelivery-fields
Jun 12, 2026
Merged

fix(uber createDelivery): send the 4 required pickup/dropoff contact fields (no more invalid_params)#495
alexpmichelet merged 2 commits into
mainfrom
agent/uber-createdelivery-fields

Conversation

@alexpmichelet

Copy link
Copy Markdown
Contributor

Le bug (prouvé ce soir avec la vraie réponse Uber)

createDelivery envoyait une requête Uber Direct Create Delivery incomplète. Avec un quote_id VALIDE, Uber renvoyait quand même HTTP 400 :

{ "code": "invalid_params", "metadata": {
    "pickup_address":        "This field is required.",
    "pickup_phone_number":   "This field is required.",
    "dropoff_name":          "This field is required.",
    "dropoff_phone_number":  "This field is required." } }

Résultat : chaque commande livraison avortait (refused_post_payment + remboursement auto) et n'atteignait jamais nouvelle. Le commentaire supposait à tort que le quote_id couvrait le pickup — il ne le fait pas : Create exige les champs contact pickup + dropoff complets, même avec un quote.

Le fix

Ajout des 4 champs requis au body POST /customers/{id}/deliveries, sourcés depuis de la donnée existante :

  • pickup_address + pickup_phone_number — depuis le tenant, EXACTEMENT comme le fait l'endpoint quote (uberPickupFromComponents → shape JSON-encodée, fallback sur la string brute pour les tenants legacy ; phone = tenant.phone).
  • dropoff_phone_numberorder.customerPhone (déjà dénormalisé sur la commande au checkout).
  • dropoff_namefirstName du client, lu via le seam sanctionné readCustomerFicheById (table customers = MOAT global, ADR 0010) par order.customerId. Fallback "Client" si absent (cosmétique, ne bloque jamais la course).

Observabilité : on console.error le status + body Uber sur un Create non-2xx (ce soir l'erreur était avalée, impossible à diagnostiquer).

interpretCreateDeliveryResponse, quote_id, manifest_items, manifest_reference, et click_and_collect (aucun appel Uber) restent inchangés.

Plan de test E2E

  • Acteur : Client PWA (eater) + système (flux payment-confirmed, no-actor)
  • Pré-requis : tenant A avec address + addressComponents (4-tuple) + phone configurés ; client avec phone (et idéalement firstName) ; credentials Uber Direct du tenant en place ; mode delivery.
  • URL : PWA Client /t/<tenantId> → menu → cart → /checkout → Payer.
  • Étapes :
    1. Le client passe une commande livraison et paie (Stripe sandbox).
    2. payment_intent.succeeded déclenche createCourseOnPaymentConfirmedcreateDelivery.
    3. Inspecter le body de la requête Create envoyée à Uber.
  • Attendu : le body contient désormais pickup_address, pickup_phone_number, dropoff_name, dropoff_phone_numberplus de 400 invalid_params. Sur acceptation Uber, la commande passe en attente de paiement → nouvelle (le resto la voit + beep). Si firstName absent → dropoff_name: "Client".
  • Couvre : groupe PAY/TRK + slice S8 — Tracking page realtime + incidents (placeholders SVG en attendant Lottie) #459 + la garantie [[Cmd avortée]] (un Create refusé reste refused_post_payment + remboursement auto, jamais nouvelle).

Note : que le SANDBOX Uber accepte ensuite la course est dépendant de l'environnement (le tenant doit avoir un phone ; le client doit avoir un phone). Validation via pnpm test (convex-test) uniquement — aucun appel Uber live, aucun déploiement depuis le worktree.

Checks

  • pnpm typecheck ✅ · pnpm lint ✅ · pnpm test ✅ (1668 tests)

🤖 Generated with Claude Code

alexpmichelet and others added 2 commits June 12, 2026 07:15
test(uber createDelivery): assert the 4 required Create fields + dropoff_name fallback

Create Delivery requires pickup_address, pickup_phone_number, dropoff_name,
dropoff_phone_number even alongside a valid quote_id. Update the createDelivery
unit test to assert all four on the request body (pickup_* from the tenant,
dropoff_* from the customer/order), add a dropoff_name="Client" fallback test,
and extend the course orchestrator test to thread + assert the four fields.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@
… fields

Uber Direct Create Delivery returns HTTP 400 invalid_params for pickup_address,
pickup_phone_number, dropoff_name and dropoff_phone_number even when a valid
quote_id is present, so every delivery course aborted (refused_post_payment +
auto-refund) and never reached `nouvelle`. The old comment wrongly assumed the
quote_id covered the pickup.

createDelivery now accepts + sends the four fields. The orchestrator
(createCourseOnPaymentConfirmed) sources them from existing data: pickup_address
+ pickup_phone_number from the tenant, built EXACTLY as the quote endpoint does
(uberPickupFromComponents JSON shape, falling back to the raw address string for
legacy tenants); dropoff_phone_number from the order denormalised customerPhone;
dropoff_name from the customer firstName (read via the sanctioned
readCustomerFicheById MOAT seam by order.customerId), falling back to "Client"
when absent (cosmetic, never blocks the course).

Also log the Uber status + body on a non-2xx Create so future refusals are
diagnosable (tonight the error was swallowed).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@vercel

vercel Bot commented Jun 12, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
kitchen-boost-repo-admin Ready Ready Preview, Comment Jun 12, 2026 5:18am
kitchen-boost-repo-web Ready Ready Preview, Comment Jun 12, 2026 5:18am

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant