dbt accepted_values test failed on churn_status column: cancelled accounts still coded as active
Fixes a dbt accepted_values test failing on the churn_status column so cancelled accounts stop being coded as active, by tracing the unexpected values to their source model. Use when the test lists values outside the allowed set. Not for relaxing the test to hide real data problems.
TL;DR
The test is the messenger, believe it. An acceptedvalues failure on churnstatus means real rows carry a status your model contract says cannot exist, usually a new value from the billing source such as a paused or incomplete state mapped to nothing, or a case and whitespace variant. Trace the offending values to the exact source rows, add an explicit mapping for each one with the business owner, and keep the test strict so the next new billing state gets caught at the door instead of corrupting churn counts.
dbt accepted_values test failed on churn_status column: cancelled accounts still coded as activeUse this when
- dbt build or test fails on acceptedvalues for churnstatus with a list of failing values
- Churn reports show cancelled accounts still counted as active, matching the failing values
- The billing source added a subscription state or changed status strings recently
Not for this skill when
- The allowed list itself is outdated by an agreed business change, which still needs the mapping and documentation fixed, not the test deleted
- The column contains nulls from a join failure, a related but distinct problem the test output will show separately
Steps
- Read the test failure output in full and capture the exact unexpected values and their row counts from the compiled test query, not from memory of the error summary. Run that query grouped by the offending value so you know whether you face one dominant new value or a long tail of junk, because the fixes differ. Verify: the offending values and counts are listed from the failing test query
- Trace each value upstream. Follow the churn_status column through the dbt lineage to the staging model and the raw billing table, and find where the value enters, whether it arrives raw from Stripe or Chargebee, is produced by a case expression with a missing branch, or leaks from a union with a legacy source that used different status words. Verify: each offending value is traced to its entry point in the lineage
- Decide the correct business mapping for each value with the churn reporting owner. A paused subscription might count as active for logo churn and at risk for revenue churn, and an incomplete or trialing state might belong outside the churn denominator entirely. Write the decision down in the model documentation at the same time as the code change so the reasoning survives. Verify: the mapping per value is decided, documented, and signed off by the reporting owner
- Implement the mapping explicitly in the staging or intermediate model with a case expression that lists every known source status and sends anything unknown to a clearly named unmapped bucket, then update the accepted_values list only if the business decision created a genuinely new allowed status. Never map unknowns silently to active, because that default is exactly how cancelled accounts hid in the active count. Verify: the model builds with explicit mappings and unknown values land in the visible unmapped bucket
- Re-run the dbt test suite for the affected models and then reconcile the business output. Compare account counts by churn_status before and after, confirm the cancelled accounts that prompted the work now count as churned, and share the restated churn numbers with everyone who quoted the old ones, because their reports changed underneath them. Verify: tests pass and the before and after status counts are reconciled and communicated
- Add a source freshness and values watch. Schedule a lightweight query that lists distinct raw billing statuses weekly and alerts when a value appears that the mapping does not cover, so the next billing state is caught when it launches rather than at month end when churn is reported. Verify: the weekly distinct values check exists and fires on a test unmapped value
Why it happens
dbt accepted_values is a contract test between the raw world and your model. Billing systems evolve their lifecycle states independently, and a mapping written for last years states has no branch for a new one, so the new value flows through untouched or lands in a default that misclassifies it. The test failure is the contract working. The churn miscount is what happens in every model that lacks such a test.
Compatibility: dbt tests including accepted_values, dbt lineage and documentation, and billing sources such as Stripe and Chargebee subscription states, in current versions.
Variants and edge cases
dbt acceptedvalues failed churnstatus values
['The direct phrasing. Work from the failing values list outward to the source, not from the test definition inward.']
cancelled accounts coded as active status mapping
['The business variant. The damage measure is how many accounts and how much revenue were misclassified and for how long, so quantify it alongside the fix.']
new Stripe subscription status breaks dbt test
['The source-change variant. Billing platforms add lifecycle states over time, so treat every new state as a mapping decision with an owner, never as noise.']
Edge cases to work through before you close the incident:
- Case and trailing spaces create phantom values. Normalise case and trim in staging before mapping, and show values quoted in diagnostics so invisible characters become visible.
- A status can mean different things for trials versus paid accounts. If the business treats them differently, model that as an explicit dimension instead of overloading churn_status.
- When you restate churn, keep the old and new series both visible for one reporting cycle with the reason labelled, or stakeholders will think churn itself jumped.
Provenance
Resolved from the public thread: https://vectle.com/posts/pst_Q4PKM5vq0X0YQBSZJm81-Q