Skip to content

dbt State introduces new model Status "reused" that breaks edr CLI commands #2311

Description

@jdglaser

Describe the bug
With the introduction of dbt State both core and Platform projects introduce a new model run status – "reused". This status occurs whenever a model is reused due to no data or code changes.

When a model run status like this occurs, upon running an edr CLI command such as edr monitor, the following error occurs:

return [
           ^
  File "/usr/local/lib/python3.11/site-packages/elementary/monitor/api/alerts/alert_filters.py", line 94, in <listcomp>
    alert for alert in alerts if apply_filters_schema_on_alert(alert, alerts_filter)
                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/elementary/monitor/api/alerts/alert_filters.py", line 53, in apply_filters_schema_on_alert
    status = Status(alert.data.status)
             ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/enum.py", line 714, in __call__
    return cls.__new__(cls, value)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/enum.py", line 1137, in __new__
    raise ve_exc
ValueError: 'reused' is not a valid Status

To Reproduce
Steps to reproduce the behavior:

  1. Run a dbt project with Elementary enabled and dbt State enable. Make sure at least one model is reused
  2. Run edr monitor from the command line after the project runs.

Expected behavior
edr monitor runs successfully.

Screenshots

Repeat error from above:

return [
           ^
  File "/usr/local/lib/python3.11/site-packages/elementary/monitor/api/alerts/alert_filters.py", line 94, in <listcomp>
    alert for alert in alerts if apply_filters_schema_on_alert(alert, alerts_filter)
                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/elementary/monitor/api/alerts/alert_filters.py", line 53, in apply_filters_schema_on_alert
    status = Status(alert.data.status)
             ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/enum.py", line 714, in __call__
    return cls.__new__(cls, value)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/enum.py", line 1137, in __new__
    raise ve_exc
ValueError: 'reused' is not a valid Status

Environment (please complete the following information):

  • Elementary CLI (edr) version: elementary-data[snowflake]==0.25.1 (latest)
  • Elementary dbt package version: 0.25.1
  • dbt version you're using: 1.11.12
  • Data warehouse: snowflake

Additional context
I believe this should be an easy fix by simply adding another enum variant here

Example Change

class Status(str, Enum):
    WARN = "warn"
    FAIL = "fail"
    SKIPPED = "skipped"
    ERROR = "error"
    RUNTIME_ERROR = "runtime error"
    PARTIAL_SUCCESS = "partial success"
    REUSED = "reused"

I have not tested this yet, but after a quick code scan, I don't believe this should break any existing behavior.

Would you be willing to contribute a fix for this issue?
Let us know if you're willing to contribute so that we'll be able to provide guidance.

I am willing to put in a fix for this. I have already contributed to the elementary-data/dbt-data-reliability package.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions