Skip to content

Commit ff057ff

Browse files
refactor: rename target→adapter_type in is_transient_error signature
Addresses Itamar's review comment — the parameter now reflects that it receives the adapter type (e.g. 'bigquery'), not the profile target name (e.g. 'dev'). No logic change; callers pass it positionally. Co-Authored-By: Itamar Hartstein <haritamar@gmail.com>
1 parent 4866840 commit ff057ff

1 file changed

Lines changed: 12 additions & 12 deletions

File tree

elementary/clients/dbt/transient_errors.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
substrings that appear in the error output. Matching is
1111
case-insensitive substring search so regex is not needed.
1212
13-
The ``target`` argument accepted by :func:`is_transient_error` should be
14-
the dbt **adapter type** (e.g. ``"bigquery"``, ``"snowflake"``), as
15-
resolved from ``profiles.yml``. When the value does not match any known
16-
adapter key (or is ``None``), **all** adapter patterns are checked
13+
The ``adapter_type`` argument accepted by :func:`is_transient_error`
14+
should be the dbt **adapter type** (e.g. ``"bigquery"``, ``"snowflake"``),
15+
as resolved from ``profiles.yml``. When the value does not match any
16+
known adapter key (or is ``None``), **all** adapter patterns are checked
1717
defensively so that transient errors are never missed.
1818
"""
1919

@@ -102,23 +102,23 @@
102102
),
103103
}
104104

105-
# Pre-computed union of all adapter-specific patterns for the unknown-target
106-
# fallback path. Built once at import time to avoid repeated iteration.
105+
# Pre-computed union of all adapter-specific patterns for the fallback path
106+
# when adapter_type is unknown. Built once at import time.
107107
_ALL_ADAPTER_PATTERNS: Tuple[str, ...] = tuple(
108108
pattern for patterns in _ADAPTER_PATTERNS.values() for pattern in patterns
109109
)
110110

111111

112112
def is_transient_error(
113-
target: Optional[str],
113+
adapter_type: Optional[str],
114114
output: Optional[str] = None,
115115
stderr: Optional[str] = None,
116116
) -> bool:
117117
"""Return ``True`` if *output*/*stderr* contain a known transient error.
118118
119119
Parameters
120120
----------
121-
target:
121+
adapter_type:
122122
The dbt adapter type (e.g. ``"bigquery"``, ``"snowflake"``),
123123
typically resolved from ``profiles.yml`` by the runner.
124124
When the value matches a key in ``_ADAPTER_PATTERNS``, only that
@@ -134,16 +134,16 @@ def is_transient_error(
134134
if not haystack:
135135
return False
136136

137-
if isinstance(target, str):
138-
adapter_patterns = _ADAPTER_PATTERNS.get(target.lower())
137+
if isinstance(adapter_type, str):
138+
adapter_patterns = _ADAPTER_PATTERNS.get(adapter_type.lower())
139139
if adapter_patterns is not None:
140140
# Known adapter — use common + adapter-specific patterns.
141141
patterns: Sequence[str] = (*_COMMON, *adapter_patterns)
142142
else:
143-
# Unknown target key (e.g. profile target name). Check all adapters.
143+
# Unknown adapter type. Check all adapters defensively.
144144
patterns = (*_COMMON, *_ALL_ADAPTER_PATTERNS)
145145
else:
146-
# No target provided; still check all adapters defensively.
146+
# No adapter type provided; check all adapters defensively.
147147
patterns = (*_COMMON, *_ALL_ADAPTER_PATTERNS)
148148

149149
return any(pattern in haystack for pattern in patterns)

0 commit comments

Comments
 (0)