Skip to content

process_freshness_result crashes with "Failed to render SQL undefined value" on dbt-fusion #2245

@prath-mg

Description

@prath-mg

Describe the bug

Running dbt source freshness with dbt-fusion causes the on_run_end hook to crash with a Jinja
"undefined value" error. The error originates in process_freshness_result when accessing
result_dict.node.unique_id — in dbt-fusion, result.to_dict() returns None for the node field
on some freshness results, which the macro does not guard against. This works fine on
dbt-core.

To Reproduce

  1. Use dbt-fusion as your dbt engine
  2. Configure sources with freshness checks
  3. Run dbt source freshness
  4. See error in on_run_end hook

[JinjaError (dbt1501)]: Failed to render SQL undefined value
(in dbt_packages/elementary/dbt_project.yml:25:1)
(in dbt_packages/elementary/macros/edr/system/hooks/on_run_end.sql:25:29)
(in dbt_packages/elementary/macros/edr/dbt_artifacts/upload_source_freshness.sql:8:23)
(in dbt_packages/elementary/macros/edr/dbt_artifacts/upload_source_freshness.sql:33:37)

Expected behavior

dbt source freshness completes without error. Freshness results are uploaded to elementary
tables (or gracefully skipped if node is unavailable).

Screenshots

Image

Environment:

  • Elementary CLI (edr) version: N/A (dbt package only)
  • Elementary dbt package version: 0.23.1
  • dbt version: dbt-fusion 2.0.0-preview.178
  • Data warehouse: Snowflake
  • Infrastructure: local dev / dbt Cloud

Additional context

The crash is in process_freshness_result at the line "unique_id": result_dict.node.unique_id
— dbt-fusion's freshness result objects return None for node in some cases (e.g. sources that
error). A null guard fixes it:

{% if result_dict.node is none or result_dict.node is undefined %}
{% do return(none) %}
{% endif %}

The caller upload_source_freshness also needs to filter none results before passing to
upload_artifacts_to_table.

Would you be willing to contribute a fix for this issue?

Yes — the fix is straightforward and we're happy to submit a PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions