Skip to content

RefundOrder tool returns clear result for missing payment records - #7

Open
sentry[bot] wants to merge 1 commit into
mainfrom
seer/fix/refund-tool-legacy-orders
Open

sentry[bot] wants to merge 1 commit into
mainfrom
seer/fix/refund-tool-legacy-orders

Conversation

@sentry

@sentry sentry Bot commented Sep 28, 2026

Copy link
Copy Markdown

This change modifies the refundOrder tool in apps/storefront/lib/ai/tools.ts to gracefully handle cases where an order has no corresponding payment record. Previously, db.selectPayment(orderId) would throw an error for such orders (e.g., legacy orders predating the payments launch), leading to an unhandled exception being captured by Sentry.

Now, the call to db.selectPayment(orderId) is wrapped in a try/catch block. If selectPayment throws, the refundOrder tool will return a structured result { refunded: false, reason: error.message }. This allows the AI to receive a clear tool result and respond gracefully to the user, preventing unhandled exceptions.

Fixes DEBUGGING-AGENTS-STOREFRONT-2

@sentry <feedback>: Autofix iterates on these changes
@sentry stop iterating: Autofix stops iterating on this run

Co-authored-by: sentry[bot] <39604003+sentry[bot]@users.noreply.github.com>
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