Skip to content

Commit 6e39e8c

Browse files
authored
Return dict str_node when doing transform (#2996)
1 parent 624ad06 commit 6e39e8c

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/cfnlint/template/transforms/_language_extensions.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import regex as re
1515

1616
from cfnlint.conditions._utils import get_hash
17+
from cfnlint.decode.node import str_node
1718
from cfnlint.helpers import FUNCTION_FOR_EACH
1819
from cfnlint.template.transforms._types import TransformResult
1920

@@ -197,10 +198,15 @@ def _replace_string_params(
197198
pattern = r"\${[a-zA-Z0-9\.:]+}"
198199
if not re.search(pattern, s):
199200
return (True, s)
201+
202+
new_s = deepcopy(s)
200203
for k, v in params.items():
201-
s = re.sub(rf"\$\{{{k}\}}", v, s)
204+
new_s = re.sub(rf"\$\{{{k}\}}", v, new_s)
205+
206+
if isinstance(s, str_node):
207+
new_s = str_node(new_s, s.start_mark, s.end_mark)
202208

203-
return (not (bool(re.search(pattern, s))), s)
209+
return (not (bool(re.search(pattern, new_s))), new_s)
204210

205211

206212
class _ForEachValue:

0 commit comments

Comments
 (0)