Skip to content

Commit d517288

Browse files
authored
Several state mach schema improvements (#4081)
1 parent 932cf2d commit d517288

File tree

2 files changed

+54
-27
lines changed

2 files changed

+54
-27
lines changed

src/cfnlint/data/schemas/other/step_functions/statemachine.json

+6-2
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,10 @@
5353
"properties": {
5454
"Choices": {
5555
"items": {
56-
"$ref": "#/definitions/choice/definitions/Operator"
56+
"$ref": "#/definitions/choice/definitions/Operator",
57+
"required": [
58+
"Next"
59+
]
5760
},
5861
"type": "array"
5962
}
@@ -1199,6 +1202,7 @@
11991202
"$ref": "#/definitions/queryLanguage"
12001203
},
12011204
"Seconds": {
1205+
"maximum": 99999999,
12021206
"minimum": 0,
12031207
"type": "number"
12041208
},
@@ -1247,7 +1251,7 @@
12471251
"States": {
12481252
"additionalProperties": false,
12491253
"patternProperties": {
1250-
"^.{1,128}$": {
1254+
"^.{1,80}$": {
12511255
"$ref": "#/definitions/state"
12521256
}
12531257
},

test/unit/rules/resources/stepfunctions/test_state_machine_definition.py

+48-25
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ def rule():
431431
"properties",
432432
"States",
433433
"patternProperties",
434-
"^.{1,128}$",
434+
"^.{1,80}$",
435435
"required",
436436
]
437437
),
@@ -446,7 +446,7 @@ def rule():
446446
"properties",
447447
"States",
448448
"patternProperties",
449-
"^.{1,128}$",
449+
"^.{1,80}$",
450450
"allOf",
451451
0,
452452
"then",
@@ -464,7 +464,7 @@ def rule():
464464
"properties",
465465
"States",
466466
"patternProperties",
467-
"^.{1,128}$",
467+
"^.{1,80}$",
468468
"allOf",
469469
3,
470470
"then",
@@ -496,7 +496,7 @@ def rule():
496496
"properties",
497497
"States",
498498
"patternProperties",
499-
"^.{1,128}$",
499+
"^.{1,80}$",
500500
"required",
501501
]
502502
),
@@ -578,7 +578,7 @@ def rule():
578578
"properties",
579579
"States",
580580
"patternProperties",
581-
"^.{1,128}$",
581+
"^.{1,80}$",
582582
"allOf",
583583
5,
584584
"then",
@@ -598,7 +598,7 @@ def rule():
598598
"properties",
599599
"States",
600600
"patternProperties",
601-
"^.{1,128}$",
601+
"^.{1,80}$",
602602
"allOf",
603603
5,
604604
"then",
@@ -674,7 +674,7 @@ def rule():
674674
"properties",
675675
"States",
676676
"patternProperties",
677-
"^.{1,128}$",
677+
"^.{1,80}$",
678678
"allOf",
679679
5,
680680
"then",
@@ -774,7 +774,12 @@ def rule():
774774
{
775775
"Condition": "BatchJobNotification",
776776
"Next": "Notify Success",
777-
}
777+
},
778+
{
779+
"Variable": "$.value",
780+
"NumericLessThan": 0,
781+
# missing next
782+
},
778783
],
779784
"Next": "Notify Success",
780785
},
@@ -822,7 +827,7 @@ def rule():
822827
"properties",
823828
"States",
824829
"patternProperties",
825-
"^.{1,128}$",
830+
"^.{1,80}$",
826831
"allOf",
827832
5,
828833
"then",
@@ -848,7 +853,7 @@ def rule():
848853
"properties",
849854
"States",
850855
"patternProperties",
851-
"^.{1,128}$",
856+
"^.{1,80}$",
852857
"allOf",
853858
5,
854859
"then",
@@ -874,7 +879,7 @@ def rule():
874879
"properties",
875880
"States",
876881
"patternProperties",
877-
"^.{1,128}$",
882+
"^.{1,80}$",
878883
"allOf",
879884
5,
880885
"then",
@@ -911,7 +916,7 @@ def rule():
911916
"properties",
912917
"States",
913918
"patternProperties",
914-
"^.{1,128}$",
919+
"^.{1,80}$",
915920
"allOf",
916921
0,
917922
"then",
@@ -926,6 +931,30 @@ def rule():
926931
),
927932
path=deque(["Definition", "States", "Choices2", "Choices", 0]),
928933
),
934+
ValidationError(
935+
("'Next' is a required property"),
936+
rule=StateMachineDefinition(),
937+
validator="required",
938+
schema_path=deque(
939+
[
940+
"properties",
941+
"States",
942+
"patternProperties",
943+
"^.{1,80}$",
944+
"allOf",
945+
0,
946+
"then",
947+
"allOf",
948+
1,
949+
"then",
950+
"properties",
951+
"Choices",
952+
"items",
953+
"required",
954+
]
955+
),
956+
path=deque(["Definition", "States", "Choices2", "Choices", 1]),
957+
),
929958
ValidationError(
930959
("'Condition' is a required property"),
931960
rule=StateMachineDefinition(),
@@ -935,7 +964,7 @@ def rule():
935964
"properties",
936965
"States",
937966
"patternProperties",
938-
"^.{1,128}$",
967+
"^.{1,80}$",
939968
"allOf",
940969
0,
941970
"then",
@@ -1067,7 +1096,7 @@ def rule():
10671096
"properties",
10681097
"States",
10691098
"patternProperties",
1070-
"^.{1,128}$",
1099+
"^.{1,80}$",
10711100
"allOf",
10721101
5,
10731102
"then",
@@ -1093,7 +1122,7 @@ def rule():
10931122
"properties",
10941123
"States",
10951124
"patternProperties",
1096-
"^.{1,128}$",
1125+
"^.{1,80}$",
10971126
"allOf",
10981127
5,
10991128
"then",
@@ -1118,7 +1147,7 @@ def rule():
11181147
"properties",
11191148
"States",
11201149
"patternProperties",
1121-
"^.{1,128}$",
1150+
"^.{1,80}$",
11221151
"allOf",
11231152
5,
11241153
"then",
@@ -1141,7 +1170,7 @@ def rule():
11411170
"properties",
11421171
"States",
11431172
"patternProperties",
1144-
"^.{1,128}$",
1173+
"^.{1,80}$",
11451174
"allOf",
11461175
0,
11471176
"then",
@@ -1164,7 +1193,7 @@ def rule():
11641193
"properties",
11651194
"States",
11661195
"patternProperties",
1167-
"^.{1,128}$",
1196+
"^.{1,80}$",
11681197
"allOf",
11691198
0,
11701199
"then",
@@ -1191,7 +1220,7 @@ def rule():
11911220
"properties",
11921221
"States",
11931222
"patternProperties",
1194-
"^.{1,128}$",
1223+
"^.{1,80}$",
11951224
"allOf",
11961225
5,
11971226
"then",
@@ -1217,10 +1246,4 @@ def test_validate(
12171246
validator,
12181247
):
12191248
errs = list(rule.validate(validator, {}, instance, {}))
1220-
for i, err in enumerate(errs):
1221-
print(i)
1222-
print(err.message, err.message == expected[i].message)
1223-
print(err.path, err.path == expected[i].path)
1224-
print(err.schema_path, err.schema_path == expected[i].schema_path)
1225-
print(err.validator, err.validator == expected[i].validator)
12261249
assert errs == expected, f"{name!r} test failed with {errs!r}"

0 commit comments

Comments
 (0)