You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-- models/any_model.sql
{% set some_list = ['a', 'b', 'c'] %}
{{ log(some_list, info = true) }}
select1as id
$ DBT_ENV_SECRET_WHATEVER=1234 dbt run
12:12:30 Running with dbt=1.2.0-a1
12:12:30 Encountered an error:
'list' object has no attribute 'replace'
I'm not even using the secret, but because I've defined one, dbt is searching log messages to scrub out any instances of the secret value. This error is not related to the recent change re: secret rendering. It's just related to how we're scrubbing secrets from log messages in general, and have been since v1.0.0:
When a user passes a non-string object into {{ log() }}, we end up passing that object straight through to scrub_secrets. Which expects to be receiving a string!
The type signature of log actually expects to be receiving a string, too:
We could put this logic anywhere, but it feels like the simplest and most appropriate fix may well be to stringify whatever users are passing into log, before firing it:
deflog(msg: str, info: bool=False) ->str:
...
# user-provided msg should be a stringmsg=str(msg)
ifinfo:
fire_event(MacroEventInfo(msg=msg))
else:
fire_event(MacroEventDebug(msg=msg))
return""
This successfully handles some pretty weird edge cases:
{{ log(this, info = true) }}
{{ log(create_table_as, info = true) }}
{{ log(context, info = true) }}
Still, we should make sure it raises a useful error, in case users try passing in objects that aren't string serializable. (I can't think of an example right now, but maybe there is one?)
The text was updated successfully, but these errors were encountered:
Reproduction case
I'm not even using the secret, but because I've defined one, dbt is searching log messages to scrub out any instances of the secret value. This error is not related to the recent change re: secret rendering. It's just related to how we're scrubbing secrets from log messages in general, and have been since v1.0.0:
dbt-core/core/dbt/events/functions.py
Lines 122 to 128 in 6e8388c
When a user passes a non-
string
object into{{ log() }}
, we end up passing that object straight through toscrub_secrets
. Which expects to be receiving a string!The type signature of
log
actually expects to be receiving a string, too:dbt-core/core/dbt/context/base.py
Lines 543 to 562 in 6e8388c
Resolution
We could put this logic anywhere, but it feels like the simplest and most appropriate fix may well be to stringify whatever users are passing into
log
, before firing it:This successfully handles some pretty weird edge cases:
Still, we should make sure it raises a useful error, in case users try passing in objects that aren't string serializable. (I can't think of an example right now, but maybe there is one?)
The text was updated successfully, but these errors were encountered: