@@ -455,7 +455,23 @@ def rule():
455455 },
456456 }
457457 },
458- [],
458+ [
459+ ValidationError (
460+ "Missing transition target 'NextState' at /States/Public/Next" ,
461+ rule = StateMachineDefinition (),
462+ path = deque (["Definition" , "States" , "Public" , "Next" ]),
463+ ),
464+ ValidationError (
465+ "Missing transition target 'NextState' at /States/ValueIsZero/Next" ,
466+ rule = StateMachineDefinition (),
467+ path = deque (["Definition" , "States" , "ValueIsZero" , "Next" ]),
468+ ),
469+ ValidationError (
470+ "Missing transition target 'NextState' at /States/ValueInTwenties/Next" ,
471+ rule = StateMachineDefinition (),
472+ path = deque (["Definition" , "States" , "ValueInTwenties" , "Next" ]),
473+ ),
474+ ],
459475 ),
460476 (
461477 "Invalid configuration" ,
@@ -524,6 +540,11 @@ def rule():
524540 ),
525541 path = deque (["Definition" , "States" , "__SucceedEntryPoint__" ]),
526542 ),
543+ ValidationError (
544+ "State 'NoType' is not reachable at /States/NoType" ,
545+ rule = StateMachineDefinition (),
546+ path = deque (["Definition" , "States" , "NoType" ]),
547+ ),
527548 ],
528549 ),
529550 (
@@ -1075,6 +1096,31 @@ def rule():
10751096 ),
10761097 path = deque (["Definition" , "States" , "Choices3" , "Choices" , 0 ]),
10771098 ),
1099+ ValidationError (
1100+ "State 'Submit Batch Job 2' is not reachable at /States/Submit Batch Job 2" ,
1101+ rule = StateMachineDefinition (),
1102+ path = deque (["Definition" , "States" , "Submit Batch Job 2" ]),
1103+ ),
1104+ ValidationError (
1105+ "State 'Submit Batch Job 3' is not reachable at /States/Submit Batch Job 3" ,
1106+ rule = StateMachineDefinition (),
1107+ path = deque (["Definition" , "States" , "Submit Batch Job 3" ]),
1108+ ),
1109+ ValidationError (
1110+ "State 'Choices1' is not reachable at /States/Choices1" ,
1111+ rule = StateMachineDefinition (),
1112+ path = deque (["Definition" , "States" , "Choices1" ]),
1113+ ),
1114+ ValidationError (
1115+ "State 'Choices2' is not reachable at /States/Choices2" ,
1116+ rule = StateMachineDefinition (),
1117+ path = deque (["Definition" , "States" , "Choices2" ]),
1118+ ),
1119+ ValidationError (
1120+ "State 'Choices3' is not reachable at /States/Choices3" ,
1121+ rule = StateMachineDefinition (),
1122+ path = deque (["Definition" , "States" , "Choices3" ]),
1123+ ),
10781124 ],
10791125 ),
10801126 (
@@ -1352,6 +1398,26 @@ def rule():
13521398 ["Definition" , "States" , "Notify Failure" , "Parameters" ]
13531399 ),
13541400 ),
1401+ ValidationError (
1402+ "State 'Submit Batch Job 2' is not reachable at /States/Submit Batch Job 2" ,
1403+ rule = StateMachineDefinition (),
1404+ path = deque (["Definition" , "States" , "Submit Batch Job 2" ]),
1405+ ),
1406+ ValidationError (
1407+ "State 'Submit Batch Job 3' is not reachable at /States/Submit Batch Job 3" ,
1408+ rule = StateMachineDefinition (),
1409+ path = deque (["Definition" , "States" , "Submit Batch Job 3" ]),
1410+ ),
1411+ ValidationError (
1412+ "State 'Choices1' is not reachable at /States/Choices1" ,
1413+ rule = StateMachineDefinition (),
1414+ path = deque (["Definition" , "States" , "Choices1" ]),
1415+ ),
1416+ ValidationError (
1417+ "State 'Choices2' is not reachable at /States/Choices2" ,
1418+ rule = StateMachineDefinition (),
1419+ path = deque (["Definition" , "States" , "Choices2" ]),
1420+ ),
13551421 ],
13561422 ),
13571423 (
@@ -1560,6 +1626,170 @@ def rule():
15601626 },
15611627 [],
15621628 ),
1629+ (
1630+ "Unreachable state at top level" ,
1631+ {
1632+ "Definition" : {
1633+ "StartAt" : "Pass One" ,
1634+ "States" : {
1635+ "Pass One" : {
1636+ "Type" : "Pass" ,
1637+ "Next" : "Success" ,
1638+ },
1639+ "Unreachable pass" : {
1640+ "Type" : "Pass" ,
1641+ "Next" : "Success" ,
1642+ },
1643+ "Success" : {
1644+ "Type" : "Succeed" ,
1645+ },
1646+ },
1647+ }
1648+ },
1649+ [
1650+ ValidationError (
1651+ "State 'Unreachable pass' is not reachable at /States/Unreachable pass" ,
1652+ rule = StateMachineDefinition (),
1653+ path = deque (["Definition" , "States" , "Unreachable pass" ]),
1654+ ),
1655+ ],
1656+ ),
1657+ (
1658+ "All states reachable via Choice transitions" ,
1659+ {
1660+ "Definition" : {
1661+ "StartAt" : "Choice" ,
1662+ "States" : {
1663+ "Choice" : {
1664+ "Type" : "Choice" ,
1665+ "Choices" : [
1666+ {
1667+ "Variable" : "$.x" ,
1668+ "NumericEquals" : 1 ,
1669+ "Next" : "Branch A" ,
1670+ }
1671+ ],
1672+ "Default" : "Branch B" ,
1673+ },
1674+ "Branch A" : {"Type" : "Succeed" },
1675+ "Branch B" : {"Type" : "Succeed" },
1676+ },
1677+ }
1678+ },
1679+ [],
1680+ ),
1681+ (
1682+ "Unreachable state in Parallel branch" ,
1683+ {
1684+ "Definition" : {
1685+ "StartAt" : "ParallelState" ,
1686+ "States" : {
1687+ "ParallelState" : {
1688+ "Type" : "Parallel" ,
1689+ "Branches" : [
1690+ {
1691+ "StartAt" : "BranchStart" ,
1692+ "States" : {
1693+ "BranchStart" : {
1694+ "Type" : "Pass" ,
1695+ "End" : True ,
1696+ },
1697+ "UnreachableBranch" : {
1698+ "Type" : "Pass" ,
1699+ "End" : True ,
1700+ },
1701+ },
1702+ }
1703+ ],
1704+ "End" : True ,
1705+ }
1706+ },
1707+ }
1708+ },
1709+ [
1710+ ValidationError (
1711+ "State 'UnreachableBranch' is not reachable at /States/ParallelState/Branches/0/States/UnreachableBranch" ,
1712+ rule = StateMachineDefinition (),
1713+ path = deque (
1714+ [
1715+ "Definition" ,
1716+ "States" ,
1717+ "ParallelState" ,
1718+ "Branches" ,
1719+ 0 ,
1720+ "States" ,
1721+ "UnreachableBranch" ,
1722+ ]
1723+ ),
1724+ ),
1725+ ],
1726+ ),
1727+ (
1728+ "Unreachable state in Map ItemProcessor" ,
1729+ {
1730+ "Definition" : {
1731+ "StartAt" : "MapState" ,
1732+ "States" : {
1733+ "MapState" : {
1734+ "Type" : "Map" ,
1735+ "ItemProcessor" : {
1736+ "StartAt" : "ProcessItem" ,
1737+ "States" : {
1738+ "ProcessItem" : {
1739+ "Type" : "Pass" ,
1740+ "End" : True ,
1741+ },
1742+ "UnreachableItem" : {
1743+ "Type" : "Pass" ,
1744+ "End" : True ,
1745+ },
1746+ },
1747+ },
1748+ "End" : True ,
1749+ },
1750+ },
1751+ }
1752+ },
1753+ [
1754+ ValidationError (
1755+ "State 'UnreachableItem' is not reachable at /States/MapState/ItemProcessor/States/UnreachableItem" ,
1756+ rule = StateMachineDefinition (),
1757+ path = deque (
1758+ [
1759+ "Definition" ,
1760+ "States" ,
1761+ "MapState" ,
1762+ "ItemProcessor" ,
1763+ "States" ,
1764+ "UnreachableItem" ,
1765+ ]
1766+ ),
1767+ ),
1768+ ],
1769+ ),
1770+ (
1771+ "State reachable only via Catch is not unreachable" ,
1772+ {
1773+ "Definition" : {
1774+ "StartAt" : "TaskState" ,
1775+ "States" : {
1776+ "TaskState" : {
1777+ "Type" : "Task" ,
1778+ "Resource" : "arn:aws:states:::lambda:invoke" ,
1779+ "Catch" : [
1780+ {
1781+ "ErrorEquals" : ["States.ALL" ],
1782+ "Next" : "ErrorHandler" ,
1783+ }
1784+ ],
1785+ "End" : True ,
1786+ },
1787+ "ErrorHandler" : {"Type" : "Succeed" },
1788+ },
1789+ }
1790+ },
1791+ [],
1792+ ),
15631793 ],
15641794)
15651795def test_validate (
0 commit comments