dbt-labs / dbt-labs/dbt

[CT-1511] A general solution for accessing attributes in the flag object safely

Open
#6,259 1 comment 0 reactions 0 assignees View on GitHub
engine:v1 type:tech-debt
Dominant language
Rust
Stars
13.8k
Forks
2.6k
Avg merge
21h 31m
Merged PRs (30d)
56

Description

## Issue

Right now in the click cli, we are trying to front load everything in [Flags](https://github.com/dbt-labs/dbt-core/blob/feature/click-cli/core/dbt/cli/main.py#L60) and then trying to use it at the root level CLI function. This makes accessing attributes defined in lower level cli functions possible, but this operation itself is not safe.

For example, right now if we try to run `docs` command with the click cli(`python core/dbt/cli/main.py docs`), we will run into error
```
File "/Users/chenyuli/git/dbt-core/core/dbt/cli/main.py", line 70, in cli
initialize_from_flags(flags.ANONYMOUS_USAGE_STATS, flags.PROFILES_DIR)
AttributeError: 'Flags' object has no attribute 'PROFILES_DIR'
```
since `PROFILES_DIR` is a parameter that is not defined in any of the command under `docs`, it never got set in `Flags`.

## potential Exit Criteria:
1. Rethink about whether construct flags at root level cli and do everything there is the method we want to go next
2. If answer to 1 is yes, then come up with solutions of making accessing potential non-existence attributes raise warning if there are cases that is not thought through(maybe through auto generated tests?). If the answer to 1 is no, then come up with new way to organize parameters and test that properly.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.