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
- Use dbt-fusion as your dbt engine
- Configure sources with freshness checks
- Run dbt source freshness
- 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
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.
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
[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
Environment:
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.