Skip to content

Commit 03e1857

Browse files
authored
Add JSONata to state machine definitions (#3909)
* Add JSONata to state machine definitions
1 parent 3b07bf7 commit 03e1857

File tree

3 files changed

+330
-3
lines changed

3 files changed

+330
-3
lines changed

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

+156
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"additionalProperties": false,
33
"definitions": {
44
"choice": {
5+
"$ref": "#/definitions/common",
56
"additionalProperties": false,
67
"definitions": {
78
"Assign": {
@@ -197,6 +198,9 @@
197198
}
198199
},
199200
"properties": {
201+
"Arguments": {
202+
"type": "object"
203+
},
200204
"Choices": {
201205
"items": {
202206
"$ref": "#/definitions/choice/definitions/Operator"
@@ -224,12 +228,21 @@
224228
"pattern": "^.{1,128}$",
225229
"type": "string"
226230
},
231+
"Output": {
232+
"type": [
233+
"string",
234+
"object"
235+
]
236+
},
227237
"OutputPath": {
228238
"type": [
229239
"string",
230240
"null"
231241
]
232242
},
243+
"QueryLanguage": {
244+
"$ref": "#/definitions/queryLanguage"
245+
},
233246
"Type": {
234247
"enum": [
235248
"Choice"
@@ -243,9 +256,67 @@
243256
],
244257
"type": "object"
245258
},
259+
"common": {
260+
"allOf": [
261+
{
262+
"if": {
263+
"properties": {
264+
"QueryLanguage": {
265+
"const": "JSONata"
266+
}
267+
},
268+
"required": [
269+
"QueryLanguage"
270+
]
271+
},
272+
"then": {
273+
"properties": {
274+
"InputPath": false,
275+
"OutputPath": false,
276+
"Parameters": false,
277+
"ResultPath": false,
278+
"ResultSelector": false
279+
}
280+
}
281+
},
282+
{
283+
"if": {
284+
"oneOf": [
285+
{
286+
"properties": {
287+
"QueryLanguage": {
288+
"const": "JSONPath"
289+
}
290+
},
291+
"required": [
292+
"QueryLanguage"
293+
]
294+
},
295+
{
296+
"not": {
297+
"required": [
298+
"QueryLanguage"
299+
]
300+
}
301+
}
302+
]
303+
},
304+
"then": {
305+
"properties": {
306+
"Arguments": false,
307+
"Output": false
308+
}
309+
}
310+
}
311+
]
312+
},
246313
"fail": {
314+
"$ref": "#/definitions/common",
247315
"additionalProperties": false,
248316
"properties": {
317+
"Arguments": {
318+
"type": "object"
319+
},
249320
"Cause": {
250321
"type": "string"
251322
},
@@ -267,12 +338,21 @@
267338
"null"
268339
]
269340
},
341+
"Output": {
342+
"type": [
343+
"string",
344+
"object"
345+
]
346+
},
270347
"OutputPath": {
271348
"type": [
272349
"string",
273350
"null"
274351
]
275352
},
353+
"QueryLanguage": {
354+
"$ref": "#/definitions/queryLanguage"
355+
},
276356
"Type": {
277357
"enum": [
278358
"Fail"
@@ -286,8 +366,12 @@
286366
"type": "object"
287367
},
288368
"map": {
369+
"$ref": "#/definitions/common",
289370
"additionalProperties": false,
290371
"properties": {
372+
"Arguments": {
373+
"type": "object"
374+
},
291375
"Assign": {
292376
"type": "object"
293377
},
@@ -394,6 +478,12 @@
394478
"pattern": "^.{1,128}$",
395479
"type": "string"
396480
},
481+
"Output": {
482+
"type": [
483+
"string",
484+
"object"
485+
]
486+
},
397487
"OutputPath": {
398488
"type": [
399489
"string",
@@ -403,6 +493,9 @@
403493
"Parameters": {
404494
"type": "object"
405495
},
496+
"QueryLanguage": {
497+
"$ref": "#/definitions/queryLanguage"
498+
},
406499
"ResultPath": {
407500
"type": [
408501
"string",
@@ -474,8 +567,12 @@
474567
"type": "object"
475568
},
476569
"parallel": {
570+
"$ref": "#/definitions/common",
477571
"additionalProperties": false,
478572
"properties": {
573+
"Arguments": {
574+
"type": "object"
575+
},
479576
"Assign": {
480577
"type": "object"
481578
},
@@ -525,12 +622,21 @@
525622
"pattern": "^.{1,128}$",
526623
"type": "string"
527624
},
625+
"Output": {
626+
"type": [
627+
"string",
628+
"object"
629+
]
630+
},
528631
"OutputPath": {
529632
"type": [
530633
"string",
531634
"null"
532635
]
533636
},
637+
"QueryLanguage": {
638+
"$ref": "#/definitions/queryLanguage"
639+
},
534640
"ResultPath": {
535641
"type": [
536642
"string",
@@ -587,8 +693,12 @@
587693
"type": "object"
588694
},
589695
"pass": {
696+
"$ref": "#/definitions/common",
590697
"additionalProperties": false,
591698
"properties": {
699+
"Arguments": {
700+
"type": "object"
701+
},
592702
"Assign": {
593703
"type": "object"
594704
},
@@ -610,6 +720,12 @@
610720
"pattern": "^.{1,128}$",
611721
"type": "string"
612722
},
723+
"Output": {
724+
"type": [
725+
"string",
726+
"object"
727+
]
728+
},
613729
"OutputPath": {
614730
"type": [
615731
"string",
@@ -619,6 +735,9 @@
619735
"Parameters": {
620736
"type": "object"
621737
},
738+
"QueryLanguage": {
739+
"$ref": "#/definitions/queryLanguage"
740+
},
622741
"Result": {},
623742
"ResultPath": {
624743
"type": "string"
@@ -639,6 +758,14 @@
639758
],
640759
"type": "object"
641760
},
761+
"queryLanguage": {
762+
"default": "JSONPath",
763+
"enum": [
764+
"JSONPath",
765+
"JSONata"
766+
],
767+
"type": "string"
768+
},
642769
"state": {
643770
"allOf": [
644771
{
@@ -804,8 +931,12 @@
804931
"type": "object"
805932
},
806933
"task": {
934+
"$ref": "#/definitions/common",
807935
"additionalProperties": false,
808936
"properties": {
937+
"Arguments": {
938+
"type": "object"
939+
},
809940
"Assign": {
810941
"type": "object"
811942
},
@@ -862,6 +993,12 @@
862993
"pattern": "^.{1,128}$",
863994
"type": "string"
864995
},
996+
"Output": {
997+
"type": [
998+
"string",
999+
"object"
1000+
]
1001+
},
8651002
"OutputPath": {
8661003
"type": [
8671004
"string",
@@ -871,6 +1008,9 @@
8711008
"Parameters": {
8721009
"type": "object"
8731010
},
1011+
"QueryLanguage": {
1012+
"$ref": "#/definitions/queryLanguage"
1013+
},
8741014
"Resource": {
8751015
"pattern": "^arn:aws:([a-z]|-)+:([a-z]|[0-9]|-)*:[0-9]*:([a-z]|-)+:[a-zA-Z0-9-_.]+(:(\\$LATEST|[a-zA-Z0-9-_\\.]+))?$",
8761016
"type": [
@@ -940,8 +1080,12 @@
9401080
"type": "object"
9411081
},
9421082
"wait": {
1083+
"$ref": "#/definitions/common",
9431084
"additionalProperties": false,
9441085
"properties": {
1086+
"Arguments": {
1087+
"type": "object"
1088+
},
9451089
"Assign": {
9461090
"type": "object"
9471091
},
@@ -963,12 +1107,21 @@
9631107
"pattern": "^.{1,128}$",
9641108
"type": "string"
9651109
},
1110+
"Output": {
1111+
"type": [
1112+
"string",
1113+
"object"
1114+
]
1115+
},
9661116
"OutputPath": {
9671117
"type": [
9681118
"string",
9691119
"null"
9701120
]
9711121
},
1122+
"QueryLanguage": {
1123+
"$ref": "#/definitions/queryLanguage"
1124+
},
9721125
"Seconds": {
9731126
"minimum": 0,
9741127
"type": "number"
@@ -1009,6 +1162,9 @@
10091162
"Comment": {
10101163
"type": "string"
10111164
},
1165+
"QueryLanguage": {
1166+
"$ref": "#/definitions/queryLanguage"
1167+
},
10121168
"StartAt": {
10131169
"type": "string"
10141170
},

src/cfnlint/rules/resources/stepfunctions/StateMachineDefinition.py

+9-3
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,15 @@ def validate(
107107
err = self._fix_message(err)
108108

109109
err.path.appendleft(k)
110-
if not err.validator.startswith("fn_") and err.validator not in [
111-
"cfnLint"
112-
]:
110+
if err.schema in [True, False]:
111+
err.message = (
112+
f"Additional properties are not allowed ({err.path[-1]!r} "
113+
"was unexpected)"
114+
)
115+
if not err.validator or (
116+
not err.validator.startswith("fn_")
117+
and err.validator not in ["cfnLint"]
118+
):
113119
err.rule = self
114120

115121
yield self._clean_error(err)

0 commit comments

Comments
 (0)