Skip to content

Commit

Permalink
core - variable interpolate fallback on keyerror (#2845)
Browse files Browse the repository at this point in the history
  • Loading branch information
kapilt authored and thisisshi committed Sep 5, 2018
1 parent 503ebcd commit 49b6af2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion c7n/utils.py
Expand Up @@ -481,7 +481,7 @@ def set_value_from_jmespath(source, expression, value, is_first=True):
source[current_key] = value


def format_string_values(obj, err_fallback=(IndexError,), *args, **kwargs):
def format_string_values(obj, err_fallback=(IndexError, KeyError), *args, **kwargs):
"""
Format all string values in an object.
Return the updated object
Expand Down
7 changes: 7 additions & 0 deletions tests/test_utils.py
Expand Up @@ -395,3 +395,10 @@ def test_format_string_values(self):
utils.format_string_values(
{'k': '{1}'}),
{'k': '{1}'})

self.assertEqual(
utils.format_string_values(
{'k': '{limit}',
'b': '{account_id}'}, account_id=21),
{'k': '{limit}',
'b': '21'})

0 comments on commit 49b6af2

Please sign in to comment.