Skip to content

[Bug] False CustomKeyInConfigDeprecation warnings for users that have moved their custom configs to meta for python models #12314

@jeremyyeo

Description

@jeremyyeo

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

dbt users that have migrated to using "custom config in meta" for their python models are experiencing CustomKeyInConfigDeprecation warnings.

Expected Behavior

No warnings as users are doing as dbt suggest.

Steps To Reproduce

Project setup:

# models/p.yml
models:
  - name: p
    config:
      materialized: table
      meta:
        custom_key: abc
# models/p.py
import pandas as pd
def model(dbt, session):
    my_custom_config = dbt.config.get("meta")["custom_key"]
    return pd.DataFrame({"id": [my_custom_config]})
$ dbt --version
Core:
  - installed: 1.11.2
  - latest:    1.11.2 - Up to date!

Plugins:
  - snowflake: 1.11.0 - Up to date!

$ dbt parse --no-partial-parse --show-all-deprecations
19:41:34  Running with dbt=1.11.2
19:41:34  Registered adapter: snowflake=1.11.0
19:41:35  [WARNING][CustomKeyInConfigDeprecation]: Deprecated functionality
Custom key `config_keys_defaults` found in `config` in file `models/p.py`.
Custom config keys should move into the `config.meta`.
19:41:35  [WARNING][CustomKeyInConfigDeprecation]: Deprecated functionality
Custom key `config_keys_used` found in `config` in file `models/p.py`. Custom
config keys should move into the `config.meta`.
19:41:35  Performance info: /Users/jeremy/git/dbt-basic/target/perf_info.json
19:41:35  [WARNING][DeprecationsSummary]: Deprecated functionality
Summary of encountered deprecations:
- CustomKeyInConfigDeprecation: 2 occurrences

Relevant log output

Environment

- OS: macOS
- Python: 3.11
- dbt: 1.11.2

Which database adapter are you using with dbt?

snowflake

Additional Context

The model does run as expected - just that users are seeing those warnings and wondering how to fix them - if you see the warning, it says custom configs need to go into meta - which is precisely what has already been done :)

$ dbt run -s p && dbt show --inline "select * from p"
19:43:49  Running with dbt=1.11.2
19:43:50  Registered adapter: snowflake=1.11.0
19:43:50  Found 1 model, 520 macros
19:43:50  
19:43:50  Concurrency: 1 threads (target='sf')
19:43:50  
19:43:50  1 of 1 START python table model sch.p .......................................... [RUN]
19:43:57  1 of 1 OK created python table model sch.p ..................................... [SUCCESS 1 in 6.93s]
19:43:58  
19:43:58  Finished running 1 table model in 0 hours 0 minutes and 7.78 seconds (7.78s).
19:43:58  
19:43:58  Completed successfully
19:43:58  
19:43:58  Done. PASS=1 WARN=0 ERROR=0 SKIP=0 NO-OP=0 TOTAL=1
19:43:59  Running with dbt=1.11.2
19:43:59  Registered adapter: snowflake=1.11.0
19:43:59  Found 1 model, 1 sql operation, 520 macros
19:43:59  
19:43:59  Concurrency: 1 threads (target='sf')
19:43:59  
Previewing inline node:
| id  |
| --- |
| abc |

Additionally, its the act of using the config in the python model that is the issue - if you rip out the usage of the custom config:

# models/p.py
import pandas as pd
def model(dbt, session):
    return pd.DataFrame({"id": [1]})

With the same yaml shown, then dbt will not emit the warning:

$ dbt parse --no-partial-parse --show-all-deprecations
19:46:45  Running with dbt=1.11.2
19:46:46  Registered adapter: snowflake=1.11.0
19:46:46  Performance info: /Users/jeremy/git/dbt-basic/target/perf_info.json

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions