DrillsNo invoices, and every dashboard is green
No invoices, and every dashboard is green
What happened
Since Tuesday, a few of Harbor’s largest and oldest teams open Billing and see “No invoices yet”, though they’ve paid every month for years. Beacon shows GET /api/invoices at a 0.00% error rate, and no alert has fired. Last week Claude Code wrapped the invoice loader in a try/catch, “so a database hiccup never breaks the page”.
Priya, forwarding a support ticketFernhill Studio says their invoice history is empty, and their auditor needs last year’s invoices by Friday. Two more teams wrote in this morning. Their invoices are in the database, I checked.
The MagisterRun it first and read what comes back. Then change the code if you like: your edits go to the review too.
Run it to see what the three teams get this morning. db and logger here are stand-ins for Harbor’s: the large team’s query times out, like it does in production.
// Loads a team's invoices for the Billing page.
// Claude Code added the try/catch: "so a database hiccup never breaks the page".
async function listInvoices(teamId) {
try {
const rows = await db.query(
"select id, number, total_cents, currency, issued_at from invoices where team_id = $1 order by issued_at desc",
[teamId],
);
return rows.map((r) => ({
id: r.id,
number: r.number,
total: r.total_cents / 100,
currency: r.currency,
issuedAt: r.issued_at,
}));
} catch {
return [];
}
}
// GET /api/invoices, simplified: it returns a status and a JSON body.
async function getInvoices(req) {
const invoices = await listInvoices(req.teamId);
return { status: 200, body: { invoices } };
}
// This morning: Fernhill (a large team), a team that signed up yesterday, and a regular team.
const fernhill = await getInvoices({ teamId: "team_4471" });
const newTeam = await getInvoices({ teamId: "team_9020" });
const regular = await getInvoices({ teamId: "team_2210" });
for (const [team, res] of [["team_4471", fernhill], ["team_9020", newTeam], ["team_2210", regular]]) {
console.log(team, res.status, JSON.stringify(res.body).slice(0, 90));
}
The code runs in your browser against stand-in data. Nothing is sent anywhere.
Your answer
Reviewed by AI against what a good fix needs. About 10 seconds.Sign in to get your answer reviewed
It's free. Anything you've typed here stays in this browser and is waiting when you come back.
Sign in with email