Skip to content

Commit

Permalink
Improve join performance (#3906)
Browse files Browse the repository at this point in the history
  • Loading branch information
kddejong authored Jan 13, 2025
1 parent c58d38a commit 0d17484
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/cfnlint/jsonschema/_resolvers_cfn.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,10 +293,12 @@ def _join_expansion(validator: Validator, instances: Any) -> Iterator[Any]:
yield [value]
return

for value, _, _ in validator.resolve_value(instances[0]):
for value, instance_validator, errs in validator.resolve_value(instances[0]):
if errs:
continue
if not isinstance(value, (str, int, float, bool)):
raise ValueError(f"Incorrect value type for {value!r}")
for values in _join_expansion(validator, instances[1:]):
for values in _join_expansion(instance_validator, instances[1:]):
yield [value] + values


Expand Down
14 changes: 14 additions & 0 deletions test/unit/module/jsonschema/test_resolvers_cfn.py
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,20 @@ def test_invalid_functions(name, instance, response):
{"Fn::Sub": "${MyResource.Arn}"},
[],
),
(
"Fn::Join uses previous values when doing resolution",
{"Fn::Join": ["-", [{"Ref": "Environment"}, {"Ref": "Environment"}]]},
[
("dev-dev", deque(), None),
("test-test", deque(), None),
("prod-prod", deque(), None),
],
),
(
"Fn::Join using a few values with a bad Ref",
{"Fn::Join": ["-", [{"Ref": "Environment"}, {"Ref": "DNE"}]]},
[],
),
],
)
def test_valid_functions(name, instance, response):
Expand Down

0 comments on commit 0d17484

Please sign in to comment.