Repository navigation
fix(billing): stop writing empty Autumn records on read failure - #844
Draft
posthog[bot] wants to merge 1 commit into
Draft
posthog[bot] wants to merge 1 commit into
posthog[bot] wants to merge 1 commit into
Conversation
A transient Postgres failure in getAutumnCustomerFields was swallowed and returned bare defaults, so getOrCreateAutumnCustomer then overwrote the stored name, email, and account type with only source metadata. - Retry the identity read once, then return null instead of defaults when it still fails. - Callers skip the Autumn write on null: the billing panel returns no state; usage tracking skips the identity write but still records the meter. - Normalize a drizzle query error before capture (statement only, drop the bound parameters, keep the driver cause) so error tracking no longer fragments per user id. Generated-By: PostHog Desktop Task-Id: b15350b1-ea09-4023-b6ad-e404b05595a4
|
Important Review skippedBot user detected. To trigger a single review, invoke the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
React Doctor found no new issues. 🎉 Reviewed by React Doctor for commit |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
getAutumnCustomerFieldsopens a Hyperdrive Postgres connection to read five identity columns. A transient Postgres internal error was swallowed and the function returned bare defaults.getOrCreateAutumnCustomer, which both reads balances and writes identity, so the record was created or touched with onlysource: thinkex.Changes
getAutumnCustomerFieldsretries the read once, then returnsnullinstead of defaults when it still fails.getWorkspaceBillingStateFn): returns no state for that load rather than overwriting the record.trackAutumnUsage): skips the identity write but still records the meter, which carries no identity.recordOperationalFailurenormalizes a drizzle query error before capture: keep the SQL statement, drop the parameter list, surface the underlying driver cause. This runs on the shared capture path, so any drizzle failure benefits.withDbinstead of a hand-rolled connect/dispose.null→ write skippedWhy
One user hit a transient Postgres failure while their billing panel loaded, and the graceful-degradation path silently corrupted their Autumn billing record. The cost is small in volume but persistent: every occurrence degrades a real record, and the per-user error titles splinter one fault into many issues as traffic grows.
Testing notes
node_modules/.bin/vp check— format, lint, and types pass.src/integrations/autumn/client.server.test.ts(retry recovery,nullon repeated failure, skip-write path) and anormalizeCapturedErrorcase inoperational-error.test.ts.vp test --run: all pass except a pre-existing, unrelated failure insrc/integrations/posthog/build.test.ts(needs PostHog build env vars; fails identically with these changes stashed).Created with PostHog Desktop from this inbox report.
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.