-
Notifications
You must be signed in to change notification settings - Fork 175
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Redact values from logs due 'duplicate key' error (#773)
* Add failing test * Fix model test naming * Add redaction looping logic * Apply suggestions from code review Co-authored-by: Doug Beatty <[email protected]> * Add changelog * Fix test case * Rename test class * Colocate redaction tests * Ignore if dbt run passes or fails * Materialize as a table instead of a view to trigger an error * Expect the run to fail with a specific error message * Reverse order of dict, assert that sensitive data is replaced * Add newline --------- Co-authored-by: Doug Beatty <[email protected]> Co-authored-by: Mike Alfare <[email protected]> (cherry picked from commit 9fa8de2)
- Loading branch information
1 parent
57a71c0
commit 1e1bfc4
Showing
4 changed files
with
48 additions
and
3 deletions.
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: Features | ||
body: Redact cases where raw data can be leaked logs | ||
time: 2023-09-15T09:15:07.430443+10:00 | ||
custom: | ||
Author: jaypeedevlin | ||
Issue: "772" |
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
33 changes: 33 additions & 0 deletions
33
tests/functional/redact_log_values/test_duplicate_key_not_in_exceptions.py
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,33 @@ | ||
import pytest | ||
|
||
from dbt.tests.util import ( | ||
run_dbt, | ||
) | ||
|
||
_MODELS__view = """ | ||
{{ config( | ||
materialized='table', | ||
) }} | ||
with dupes as ( | ||
select 'foo' as key, 1 as value | ||
union all | ||
select 'foo' as key, 2 as value | ||
) | ||
select | ||
object_agg(key, value) as agg | ||
from dupes | ||
""" | ||
|
||
|
||
class TestDuplicateKeyNotInExceptions: | ||
@pytest.fixture(scope="class") | ||
def models(self): | ||
return {"model.sql": _MODELS__view} | ||
|
||
def test_row_values_were_scrubbed_from_duplicate_merge_exception(self, project): | ||
result = run_dbt(["run", "-s", "model"], expect_pass=False) | ||
assert len(result) == 1 | ||
assert "Duplicate field key '[redacted]'" in result[0].message | ||
assert "'foo'" not in result[0].message |
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