Testing · rule dagster-asset-unchecked
Dagster assets with no asset check
A Metacenta review checks this under the rule Dagster assets have an asset check. Everything below applies whether or not you ever commission one.
What this rule checks
This rule flags Dagster assets with no @asset_check targeting them in the same file. When more than half the assets have none, we report it once for the project rather than once per asset.
Why it matters
A materialisation can succeed while writing wrong data, and nothing downstream is told. The run shows green, so the problem surfaces in a report rather than in Dagster.
How to fix it
Add asset checks to the Dagster assets. Add an @asset_check for each asset's grain and keys, starting with the assets people read most.
Before:
@asset
def orders(raw_orders):
...
After:
@asset
def orders(raw_orders):
...
@asset_check(asset=orders)
def orders_one_row_per_order(orders):
duplicated = orders["order_id"].duplicated().sum()
return AssetCheckResult(passed=bool(duplicated == 0))
When it is fine to leave
An asset whose checks run elsewhere, such as dbt tests on the models a dbt asset builds, is covered. So is a check defined in another file, which this rule cannot see. Tell us which applies, and the finding comes out of your report.
What we need to check it
The Dagster Python files you supply. We read only what they declare (assets, checks, owners), so the finding is medium confidence.