dbt-labs / dbt-docs

Auto-generated data documentation site for dbt projects
Apache License 2.0
141 stars 75 forks source link

Meta configs in model details are not rendered in docs site #230

Closed jeremyyeo closed 2 years ago

jeremyyeo commented 2 years ago

Describe the bug

Models meta config are not being rendered in the docs site. Columns meta config however are rendered just fine.

Steps To Reproduce

With a very basic project and the following schema.yml file:

version: 2

models:
  - name: my_model
    description: "Test description"
    config:
      meta:
        contains_pii: "true"
    columns:
      - name: user_name
        meta:
          contains_pii: "true"
  - name: my_model_2
    config:
      meta:
        my_meta: "test"
    columns:
      - name: user_name
        meta:
          my_meta: "test"

Generate docs (dbt docs generate) and then inspect them.

Expected behavior

Config meta key-values should render under model details just like column details.

Screenshots and log output

Screen Shot 2022-01-17 at 11 49 21 AM

Gif: 2022-01-17 11 00 01

The output of dbt --version:

1.0.1

Tested in both core and cloud but same behaviour.

Additional context

This behaviour is also reproduced when using the meta config within the model file itself:

-- my_model.sql

{{ config(meta = {'contains_pii': 'true'}) }}

select 1 as user_name

Note that this doesn't affect dbt execution in terms of selection models to run via the meta config (e.g. dbt run -s config.meta.contains_pii:true) but more of a UI rendering issue with the docs site.

Best guess currently is due to this: https://github.com/dbt-labs/dbt-docs/blob/main/src/app/components/table_details/table_details.js#L23 (though to be honest, not really that familiar with the docs site / angular).

jtcohen6 commented 2 years ago

Thanks @jeremyyeo! I think this is actually a dbt-core bug: https://github.com/dbt-labs/dbt-core/issues/4459

The contents of node.config.meta are not successfully copied over to node.meta, even though this was our intention, so they're missing from node.meta in manifest.json. While the docs site code could work around this in the meantime by peeking into both node.config.meta and node.meta, I'd prefer to resolve this by achieving more consistent behavior in the metadata artifacts produced by dbt-core.

jeremyyeo commented 2 years ago

@jtcohen6 Aha thanks for the enlightenment - honestly I peeked into the manifest and found that node.config.meta was populated with my meta key values and thought this seemed like a docs site issue (which I guess it kinda-ish is since it doesn't actually read config.meta). I'll close this and move to that linked core issue.