Skip to content

Commit 2ab6759

Browse files
authored
Continue on template decode errors (#3605)
* Continue on template decode errors
1 parent 68ac3a6 commit 2ab6759

File tree

2 files changed

+58
-6
lines changed

2 files changed

+58
-6
lines changed

src/cfnlint/runner.py

+3-6
Original file line numberDiff line numberDiff line change
@@ -293,12 +293,9 @@ def _validate_filenames(self, filenames: Sequence[str | None]) -> Iterator[Match
293293
"E0000".startswith(x) for x in self.config.ignore_checks
294294
):
295295
matches = [match for match in matches if match.rule.id != "E0000"]
296-
if matches:
297-
yield from iter(matches)
298-
return
299-
else:
300-
yield from iter(matches)
301-
return
296+
297+
yield from iter(matches)
298+
continue
302299
yield from self.validate_template(filename, template) # type: ignore[arg-type] # noqa: E501
303300

304301
def validate_template(

test/unit/module/runner/test_run.py

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
"""
2+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
SPDX-License-Identifier: MIT-0
4+
"""
5+
6+
import pytest
7+
8+
from cfnlint.config import ConfigMixIn
9+
from cfnlint.runner import Runner
10+
11+
12+
@pytest.mark.parametrize(
13+
"name,config,expected_count",
14+
[
15+
(
16+
"Test decode errors with multiple files",
17+
ConfigMixIn(
18+
cli_args=[
19+
"--template",
20+
"test/fixtures/templates/bad/duplicate.yaml",
21+
"test/fixtures/templates/bad/duplicate.json",
22+
]
23+
),
24+
6,
25+
),
26+
(
27+
"Test decode errors with E0000 being ignored",
28+
ConfigMixIn(
29+
cli_args=[
30+
"--template",
31+
"test/fixtures/templates/bad/core/parse_invalid_map.yaml",
32+
"--ignore-bad-template",
33+
]
34+
),
35+
0,
36+
),
37+
(
38+
"Test decode return E0000 errors",
39+
ConfigMixIn(
40+
cli_args=[
41+
"--template",
42+
"test/fixtures/templates/bad/core/parse_invalid_map.yaml",
43+
]
44+
),
45+
1,
46+
),
47+
],
48+
)
49+
def test_run(name, config, expected_count):
50+
51+
runner = Runner(config)
52+
53+
errs = list(runner.run())
54+
55+
assert len(errs) == expected_count, f"{name}: {errs}"

0 commit comments

Comments
 (0)