Skip to content

feat: warn on unknown flags in dbt_project.yml#12689

Closed
chinar-amrutkar wants to merge 5 commits into
dbt-labs:mainfrom
chinar-amrutkar:feat/strict-flags
Closed

feat: warn on unknown flags in dbt_project.yml#12689
chinar-amrutkar wants to merge 5 commits into
dbt-labs:mainfrom
chinar-amrutkar:feat/strict-flags

Conversation

@chinar-amrutkar
Copy link
Copy Markdown
Contributor

@chinar-amrutkar chinar-amrutkar commented Mar 21, 2026

Closes #12590

Problem

When users set flags in dbt_project.yml that dbt doesn't recognize (e.g., typos like prrint instead of print), dbt silently ignores them. There's no feedback to the user that their configuration is being ignored, leading to confusion when expected behavior doesn't change.

Solution

Added validation in read_project_flags() at core/dbt/config/project.py that compares the user's flags against known ProjectFlags field names. Unknown flags trigger a warning via fire_event(InvalidOptionYAML(...)), guiding users to fix their config.

The warning message lists the first 10 known flag names to help users identify the correct option.

Checklist

  • I have read the contributing guide and understand what's expected of me.
  • I have run this code in development, and it appears to resolve the stated issue.
  • This PR includes tests, or tests are not required or relevant for this PR.
  • This PR has no interface changes (e.g., macros, CLI, logs, JSON artifacts, config files, adapter interface, etc.) or this PR has already received feedback and approval from Product or DX.
  • This PR includes type annotations for new and modified functions.

@chinar-amrutkar chinar-amrutkar requested a review from a team as a code owner March 21, 2026 22:36
@cla-bot cla-bot Bot added the cla:yes label Mar 21, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Thank you for your pull request! We could not find a changelog entry for this change. For details on how to document a change, see the contributing guide.

@github-actions github-actions Bot added the community This PR is from a community member label Mar 21, 2026
Comment thread core/dbt/config/project.py
Comment thread core/dbt/config/project.py Outdated
@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 23, 2026

Codecov Report

❌ Patch coverage is 37.50000% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.14%. Comparing base (b62928f) to head (6c4cc2e).
⚠️ Report is 13 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #12689      +/-   ##
==========================================
- Coverage   91.41%   88.14%   -3.27%     
==========================================
  Files         203      203              
  Lines       25883    25890       +7     
==========================================
- Hits        23662    22822     -840     
- Misses       2221     3068     +847     
Flag Coverage Δ
integration 88.14% <37.50%> (-0.14%) ⬇️
unit ?

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
Unit Tests 88.14% <37.50%> (-3.27%) ⬇️
Integration Tests 88.14% <37.50%> (-0.14%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sriramr98
Copy link
Copy Markdown
Contributor

sriramr98 commented Mar 25, 2026

Hi @chinar-amrutkar . We require all commits to be signed and the first commit in this PR isn't signed. There are also some failures from black which can be fixed through pre-commit

Can you take care of it so that I can take this PR forward?

Comment thread core/dbt/config/project.py
Comment thread .changes/unreleased/Features-20260321-225400.yaml
Comment thread core/dbt/config/project.py Outdated
Comment thread .changes/unreleased/Features-20260321-225400.yaml
Comment thread core/dbt/config/project.py Outdated
Comment thread tests/unit/config/test_project.py Outdated
Copy link
Copy Markdown
Contributor

@sriramr98 sriramr98 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are still two commits which aren't verified. Can you fix them?

@chinar-amrutkar
Copy link
Copy Markdown
Contributor Author

@sriramr98 I have updated the commits and they are now verified. I have implemented the other requested changes as well.

@chinar-amrutkar
Copy link
Copy Markdown
Contributor Author

@MichelleArk could you kindly review when you have a moment? Thank you!

@sriramr98
Copy link
Copy Markdown
Contributor

sriramr98 commented Apr 6, 2026

@chinar-amrutkar It looks like some relevant unit tests are failing. Can you take a look at them?

black is still failing as a part of our pre-commit hooks. These issues would need to be fixed before we can take this PR further

chinar-amrutkar and others added 5 commits April 6, 2026 09:59
Add validation to warn users when they set flags in dbt_project.yml
that dbt doesn't recognize. This helps prevent conflicts with future
dbt flags and makes it clearer what's 'official' vs custom.

When unknown flags are detected, fires an InvalidOptionYAML event
listing the unknown flags and a sample of valid ones.

Closes dbt-labs#12590
…ture

- Move InvalidOptionYAML and fire_event imports to top of project.py
- Move InvalidOptionYAML and read_project_flags imports to top of test_project.py
- Fix changelog YAML: Issue should be child of custom, not top-level issues list
@chinar-amrutkar
Copy link
Copy Markdown
Contributor Author

@sriramr98 could you kindly approve the CI workflow so that I can check the tests?

@sriramr98
Copy link
Copy Markdown
Contributor

sriramr98 commented Apr 8, 2026

Hey @chinar-amrutkar . Apologies for the delay. The unit tests are still failing.

For future ref - You don't have to wait for a contributor to approve running the tests. You can run hatch run unit-tests locally which will run all tests and give you immediate feedback for you to contribute faster.

I also don't see signed commits in this PR. The commits should be signed for us to merge this PR once everything checks out.

@sriramr98
Copy link
Copy Markdown
Contributor

Closing this PR due to inactivity. Same changes with minor modifications in this PR

Thanks for the initial work @chinar-amrutkar

@sriramr98 sriramr98 closed this Apr 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla:yes community This PR is from a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] make flags: list strict

3 participants