-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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] Exclude password-like fields for considering reparse #9844
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
2f78af0
hash connection_keys as profile
ChenyuLInx 11fc733
changlog
ChenyuLInx 42bbe7a
nits
ChenyuLInx e44b328
nits
ChenyuLInx 3ce11ef
adjust
ChenyuLInx c3f4389
adjust
ChenyuLInx 1055202
adjust_vars
ChenyuLInx f07a86b
nits
ChenyuLInx File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
kind: Fixes | ||
body: Exclude password-like fields for considering reparse | ||
time: 2024-04-02T13:55:56.169953-07:00 | ||
custom: | ||
Author: ChenyuLInx | ||
Issue: "9795" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -314,40 +314,33 @@ def dbt_profile_target(self): | |
# calls 'load_config' before the tests are run. | ||
# Note: only the specified profile is rendered, so there's no | ||
# point it setting env_vars in non-used profiles. | ||
os.environ["ENV_VAR_USER"] = "root" | ||
os.environ["ENV_VAR_PASS"] = "password" | ||
os.environ["ENV_VAR_HOST"] = "localhost" | ||
return { | ||
"type": "postgres", | ||
"threads": 4, | ||
"host": "localhost", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @gshank I think the adjust to the test here makes sense since user and pass are not in |
||
"host": "{{ env_var('ENV_VAR_HOST') }}", | ||
"port": 5432, | ||
"user": "{{ env_var('ENV_VAR_USER') }}", | ||
"pass": "{{ env_var('ENV_VAR_PASS') }}", | ||
"user": "root", | ||
"pass": "password", | ||
"dbname": "dbt", | ||
} | ||
|
||
def test_profile_env_vars(self, project, logs_dir): | ||
|
||
# Initial run | ||
os.environ["ENV_VAR_USER"] = "root" | ||
os.environ["ENV_VAR_PASS"] = "password" | ||
os.environ["ENV_VAR_HOST"] = "localhost" | ||
|
||
run_dbt(["run"]) | ||
manifest = get_manifest(project.project_root) | ||
env_vars_checksum = manifest.state_check.profile_env_vars_hash.checksum | ||
|
||
# Change env_vars, the user doesn't exist, this should fail | ||
os.environ["ENV_VAR_USER"] = "fake_user" | ||
os.environ["ENV_VAR_HOST"] = "wrong_host" | ||
|
||
# N.B. run_dbt_and_capture won't work here because FailedToConnectError ends the test entirely | ||
with pytest.raises(FailedToConnectError): | ||
run_dbt(["run"], expect_pass=False) | ||
|
||
log_output = Path(logs_dir, "dbt.log").read_text() | ||
assert "env vars used in profiles.yml have changed" in log_output | ||
|
||
manifest = get_manifest(project.project_root) | ||
assert env_vars_checksum != manifest.state_check.profile_env_vars_hash.checksum | ||
assert "Unable to do partial parsing because profile has changed" in log_output | ||
|
||
|
||
class TestProfileSecretEnvVars: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't want to convert connection_info to a list, that removes the values from the connection_info dictionary. We need to preserve them, because it's changes in the values that force a re-parse. In other places in the code we hash a dictionary for profiles_env_var_hash and and project_env_vars_hash, but any method that turns a dictionary into something hashable would work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, we don't really need profile_env_vars_hash anymore after doing this since the env_vars would be resolved. So we might want to remove that part, since it will cause extra churn in parts of the profile that may not be being used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So connection_info returns a iterator, after converting to a list it will look like [(key1, value1), (key2, value2)].
I will get the profile
env_var_hash
part adjusted