Checkout answers a failed read of the organization's billing accounts as "no billing account found" with 400 #204

Open
opened 2026-10-09 16:02:11 +00:00 by cgalo5758 · 0 comments
Owner

What happens

When a member starts Checkout from a plan card or an add-on on the Products page, HandleCheckout reads the organization's billing accounts (ListBillingAccountsByOrgID) before it asks whether the plan is offered. A database error in that read is treated the same as finding no account: the handler answers 400 with "no billing account found", and the log line says "no billing account found" without the error. The text lands in the error slot under the button, and the page's error handler adds the toast meant for a request the member got wrong: "Request failed. Please check your input and try again."

Every other read in HandleCheckout (the price, the product and its ladders, the plan position, the price mapping, the customer mapping) logs the database error and answers 500. A 500 leaves the slot alone and shows the "Server error" toast.

What should happen

A failed read of the accounts logs the error and answers 500, as Checkout's other failed reads do. Only an empty result gets the no-account answer. A test drives the failed read and asserts the 500.

Where

internal/server/billing.go (HandleCheckout). #182 asks for one query that returns the organization's own account. With that query, a missing account is sql.ErrNoRows and any other error is a failure.

Why it matters

During a passing database fault, a member trying to pay is told their organization has no billing account and that their input was wrong. The log records a missing account, not the fault.

## What happens When a member starts Checkout from a plan card or an add-on on the Products page, `HandleCheckout` reads the organization's billing accounts (`ListBillingAccountsByOrgID`) before it asks whether the plan is offered. A database error in that read is treated the same as finding no account: the handler answers 400 with "no billing account found", and the log line says "no billing account found" without the error. The text lands in the error slot under the button, and the page's error handler adds the toast meant for a request the member got wrong: "Request failed. Please check your input and try again." Every other read in `HandleCheckout` (the price, the product and its ladders, the plan position, the price mapping, the customer mapping) logs the database error and answers 500. A 500 leaves the slot alone and shows the "Server error" toast. ## What should happen A failed read of the accounts logs the error and answers 500, as Checkout's other failed reads do. Only an empty result gets the no-account answer. A test drives the failed read and asserts the 500. ## Where `internal/server/billing.go` (`HandleCheckout`). #182 asks for one query that returns the organization's own account. With that query, a missing account is `sql.ErrNoRows` and any other error is a failure. ## Why it matters During a passing database fault, a member trying to pay is told their organization has no billing account and that their input was wrong. The log records a missing account, not the fault.
cgalo5758 added the
kind
bug
area/billingarea/member-ui
labels 2026-10-09 16:02:11 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: wiki-cafe/member-console#204