Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Docs markdown not working with versioned model #11151

Open
2 tasks done
harshjets opened this issue Dec 13, 2024 · 1 comment
Open
2 tasks done

[Bug] Docs markdown not working with versioned model #11151

harshjets opened this issue Dec 13, 2024 · 1 comment
Labels
bug Something isn't working cloud Issues related to dbt Cloud dbt-docs [dbt feature] documentation site, powered by metadata artifacts model_versions

Comments

@harshjets
Copy link

Is this a new bug in dbt-core?

  • I believe this is a new bug in dbt-core
  • I have searched the existing issues, and I could not find an existing issue for this bug

Current Behavior

versions:
- v: 1
description: '{{ doc("dim_customer_v1") }}'

On save get this error

Encountered an error:
Compilation Error
Could not render {{ doc("dim_customer_v1") }}: 'doc' is undefined

Expected Behavior

No error should occur as the doc md has be defined

Steps To Reproduce

  1. Add a markdown to the description of a versioned model
  2. Error of doc not defined will show up

Relevant log output

No response

Environment

- OS:mac
- Python:
- dbt:1.9

Which database adapter are you using with dbt?

No response

Additional Context

Screenshot 2024-12-13 at 10 27 30 AM

@harshjets harshjets added bug Something isn't working triage labels Dec 13, 2024
@dbeatty10 dbeatty10 added dbt-docs [dbt feature] documentation site, powered by metadata artifacts model_versions cloud Issues related to dbt Cloud labels Dec 13, 2024
@dbeatty10
Copy link
Contributor

Thanks for reporting this @harshjets !

I see what you are saying. See below for full details to reproduce this along with the (imperfect!) workarounds in the meantime.

Reprex

Create these files:

models/dim_customers_v1.sql

select 1 as id

models/dim_customers.md

{% docs dim_customers %}

# docs
- go
- here
 
{% enddocs %}

models/_models.yml

models:
  - name: dim_customers
    latest_version: 1
    versions:
      - v: 1
        description: "{{ doc('dim_customers') }}"

Run this command:

dbt docs generate

Get this error:

Compilation Error
  Could not render {{ doc('dim_customers') }}: 'doc' is undefined

Implementation

I think we'll need to make sure that docs blocks are in the context when rendering any Jinja that is within the description field underneath v: keys.

Workaround

The only workaround in the meantime is either of these two options:

1. Use a shared top-level docs block for all versions of the model

models:
  - name: dim_customers
    description: "{{ doc('dim_customers') }}"
    latest_version: 1
    versions:
      - v: 1

2. Exclude Jinja / docs blocks from the version description

models:
  - name: dim_customers
    latest_version: 1
    versions:
      - v: 1
        description: "Docs for v1"

@dbeatty10 dbeatty10 removed the triage label Dec 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working cloud Issues related to dbt Cloud dbt-docs [dbt feature] documentation site, powered by metadata artifacts model_versions
Projects
None yet
Development

No branches or pull requests

2 participants