mirror of
https://github.com/floci-io/floci.git
synced 2026-11-23 14:10:49 -05:00
225233c19256b4e62f7c43e0131d3cf5d2d263dd
23
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
63a2a60a30 |
fix(stepfunctions): let a mocked response with no attempts start the execution (#2823)
A MockedResponses entry with no attempt keys was rejected at StartExecution, so a generated mock file failed the whole execution when the collection it was built from was empty. Step Functions Local starts the execution and fails it with States.Runtime only when the state that names the entry is entered. An empty entry is a lookup that finds nothing, not a malformed entry. Floci already accepts a mock that defines attempt 1 but not attempt 0 and fails the same way at run time. Every other malformed entry keeps its 400 at StartExecution, which stays stricter than Step Functions Local. Verified against amazon/aws-stepfunctions-local:2.0.0. Refs #2523 |
||
|
|
f7f16cd2a3 |
fix(stepfunctions): bound $range allocation at the AWS memory limit (#2790)
* fix(stepfunctions): open a JSONata query evaluation cause with the AWS sentence evaluateField now wraps a thrown JSONata failure with "The JSONata expression '<expr>' specified for the field '<field>' threw an error during evaluation" before the existing tail, matching real AWS. The separator is ". " when the tail carries a JSONata error code and ": " when it is a bound message with none. evaluate() keeps producing the bare tail unchanged for its direct callers. evaluate() stays the only place the JSONata engine is called and the only catch around it: evaluateField calls it and enriches the failure it throws, rather than reaching the engine itself. QueryEvaluationFailure carries the separator across that throw, so a catch added to evaluate() later covers both entry points. All 11 AslExecutor call sites reach the evaluator through evaluateField or resolveTemplate, so a catch installed anywhere else would be dead on every real execution path. * fix(stepfunctions): catch Error from JSONata evaluation as States.QueryEvaluationError An OutOfMemoryError or StackOverflowError raised while parsing or evaluating a JSONata expression escaped JsonataEvaluator's catch (Exception) and reached AslExecutor's own last-resort catch (Error), failing the whole execution as States.Runtime before the state's own Retry and Catch ever ran. JsonataEvaluator.evaluate now also catches Error at the same seam and translates it into a FailStateException with States.QueryEvaluationError, so a Catch on the state (or on States.ALL) can recover, matching real AWS. Closes #2738 * fix(stepfunctions): match AWS on the JSONata expressions it refuses Four expression classes where Floci and AWS disagreed on whether the state fails at all, all measured against us-east-1 with test-state. The evaluation-depth ceiling drops from 500 to 100, which is AWS's own: five nesting shapes bisected one n at a time all put its last accepted evaluation at depth 100 and its first refusal at 101. An addition chain nests one level per term and AWS accepts 100 terms; parentheses, brackets and the chain operator nest one level more than their count and AWS accepts 99 of each; a non-tail-recursive $f(n) nests 3n+5 and AWS accepts n=31, depth 98, refusing n=32, depth 101. The memory an expression may hold is now bounded, which it was not: one value an evaluation step produces may hold 6,990,256 bytes, counting a number as eight and a character as one. The two shapes AWS was bisected on, [1..873782] and a string doubled 22 times, bracket a number at between five and nine bytes a character: with the bound at 873,782 numbers, anything in that range leaves 4,194,304 characters inside it and 8,388,608 outside, and four or ten does not. Eight is what a double costs, and it is inside the bracket. The check walks the value and stops at the bound, and a lazy range is counted from its length rather than materialised. $eval is unbound, as AWS disables it, so a call to it answers T1006 the way AWS does and $parse stays the replacement. A non-finite number the expression itself evaluates to comes back as the string AWS writes for it, since JSON has no literal for one: 1/0 and 1e308*10 are "Infinity" and $parseInteger("abc","0") is "NaN", where the first two raised D1001 and the third returned nothing and failed the field. One the library's arithmetic buries inside a value, as in [1/0], still fails the state, because the refusal is the only place the library leaves the value and it has already unwound what was being built; one a function answers nests like any other value. $formatNumber checks its picture string against the fourteen rules of XPath F&O 4.7.3 first, so $formatNumber(1, "x") fails with D3086 instead of answering "x1". Which of the fourteen codes AWS reports is what fixes the order the rules are read in: a picture with no digit breaks D3085 and D3086 at once and AWS reports the second, so the last rule broken names the failure rather than the first. Closes #2737 * fix(stepfunctions): bound $range allocation at the AWS memory limit AWS accepts $range(1, 360145, 1), all 360,145 elements, and refuses one element more on its own memory limit. Floci's $range had no such bound: it built the array in full before the memory check on the value ever ran, so a call far past AWS's limit spent gigabytes and either exhausted the heap or hung instead of failing the state cleanly. range() now refuses a call whose produced element count exceeds the measured bound before allocating, throwing the same States.QueryEvaluationError JException the held-memory check raises, whose message is now a single shared constant. Other built arrays keep the looser, byte-based bound. * test(stepfunctions): pin the number model of the execution input Measured against real AWS (test-state, 2026-08-30): a Pass state with Output {"v": "{% $states.input.amount %}"} answers {"v": 1} for input {"amount": 1.0} and {"v": 9.223372036854776E18} for input {"amount": 9223372036854775808}. That is exactly what routing the execution input through toJsonataValue/toJsonataNumber already produces, so these two tests pin it against silent regression. --------- Co-authored-by: Facundo Paredes <25681464+facuparedes@users.noreply.github.com> |
||
|
|
ead70eae4d |
fix(stepfunctions): refuse the definitions AWS refuses, at both validation entry points (#2786)
* fix(stepfunctions): reject definitions with no terminal state, dangling targets or unsupported fields Enforce the ASL rules AWS applies at both ValidateStateMachineDefinition and CreateStateMachine: a workflow needs a terminal state (MISSING_END_STATE, top-level only, suppressing the unreachable-state reachability check but not a dangling-target check), every reachable state and every Next/Choices[].Next/Default/Catch[].Next target must exist (MISSING_TRANSITION_TARGET), recursing into ItemProcessor and Branches with structured paths, and TimeoutSeconds/Catch/Retry are refused outside the state types that support them (SCHEMA_VALIDATION_FAILED, "Field '<name>' is not supported"). CreateStateMachine's wire message always renders " at <location>", printing the literal "null" when there is none, matching AWS exactly; ValidateStateMachineDefinition keeps omitting the location field entirely when null, which is the correct, unchanged behavior for that API. Remove the now-dead Parallel TimeoutSeconds handling in AslExecutor: no definition carrying that field can reach execution anymore. * fix(stepfunctions): reject JSONata expressions that do not parse at definition time Report INVALID_JSONATA_EXPRESSION when a JSONata expression fails to parse, using the parser's own message with its S0xxx code prefix stripped, at the field's location. Also report UNSUPPORTED_JSONATA_EXPRESSION for '$$' and for '$states.errorOutput' outside a Catch entry's own Output or Assign. Previously these were accepted at ValidateStateMachineDefinition and CreateStateMachine time and only failed later, at execution, with States.QueryEvaluationError. Every message asserted was measured against real AWS us-east-1 with `aws stepfunctions validate-state-machine-definition`, including `phone %.other` and the empty expression, which AWS also refuses. The three booleans the definition walk threaded through every recursive call (insidePayload, isCatchEntry, insideCatchOutputOrAssign) travel as a single JsonataScope value, which drops collectTopLevelReferences back under the Sonar S3776 limit. --------- Co-authored-by: Facundo Paredes <25681464+facuparedes@users.noreply.github.com> |
||
|
|
9288769607 |
fix(stepfunctions): bound a running execution the four ways AWS does (#2782)
* fix(stepfunctions): enforce both TimeoutSeconds clocks The state machine's top-level TimeoutSeconds was read back by DescribeStateMachine and copied into activityScheduledEventDetails but never used as a deadline, so an execution ran to completion however long it took. Compute the budget once in doExecute, check it before every state and inside the Wait sleep, and end the execution TIMED_OUT with stopDate set, no error, no cause, and one ExecutionTimedOut event carrying States.Timeout and previousEventId 0. A Task's two bounds were swapped: HeartbeatSeconds acted as the total wait and TimeoutSeconds was decorative, so "TimeoutSeconds": 5, "HeartbeatSeconds": 60 failed at 60 seconds instead of 5. awaitToken now bounds the whole wait with TimeoutSeconds and the gap between heartbeats with HeartbeatSeconds. SendTaskHeartbeat only logged, so the gap bound needed a per-token timestamp: the service now records one when the token is registered and again on every heartbeat, and forgets it when the waiting task stops listening. Either clock ends the state as a TaskTimedOutException, which is what us-east-1 answers for a heartbeat expiry: an ActivityTimedOut event carrying error States.Timeout and no cause, then an execution reading FAILED with error States.Timeout and no cause key, over the six-event history ExecutionStarted, TaskStateEntered, ActivityScheduled, ActivityStarted, ActivityTimedOut, ExecutionFailed. A Catch still matches a heartbeat expiry under States.HeartbeatTimeout, so ErrorEquals matching now asks the failure which names it answers to rather than comparing one string. The Wait sleep stops at the execution deadline instead of sleeping its full duration first, which would have reported the timeout as many seconds late as the Wait outlasts the budget and left a WaitStateExited behind for a state AWS never finished. awaitToken discards its token on the way out; without that the token would stay pending for the life of the process and a later SendTaskSuccess would be answered as if someone were still waiting. Neither timeout carries a cause, so failExecution now reads a null cause as the failure having none and leaves the key out of both DescribeExecution and the ExecutionFailed event. The two other failures that reach it without a cause -- a Fail state with no Cause, and SendTaskFailure with no cause -- keep reporting an empty one, since AWS's shape for those is unmeasured. Refs #2733 * fix(stepfunctions): bound an execution's history and make StopExecution stop it AWS puts two bounds on a running execution that floci did not: it ends one that reaches 25,000 history events with States.Runtime, event 25,000 being the ExecutionFailed event itself, and StopExecution stops the worker rather than relabelling an execution that goes on to overwrite the status it wrote. Counting an event against that limit and numbering it in the published history are two meanings that one AtomicLong was carrying. They are separated here. producedEventCount counts every event the execution produces, the top-level flow's and those of its Parallel branches and inline Map iterations alike, and is what the limit judges. The published history numbers its own events: an event's id is its position in the list, which makes the list the only authority for the next id, where the counter and the seal in StepFunctionsService used to be a second one that agreed with it only at rest. A branch's events are counted and never built, so executeBranch no longer assembles HistoryEvent objects with full input and output JSON into a list it throws away. A Distributed Map runs each item as a child execution on AWS, and a child execution has a history of its own, so its items are counted against their own limit rather than the parent's: a Distributed Map over 13,000 items no longer fails the parent partway through with States.Runtime. The count is taken before it is judged. Reading it and then taking it let 40 concurrent inline Map iterations through the same check and spent more events than the execution had. StopExecution records its abort against a history that need not be in memory. Executions are stored and histories are not, so a restart in persistent mode brings a RUNNING execution back with nothing behind it, and the same window opens between a reset emptying the cache and emptying the store; the abort was written to the store and then thrown away as a 500. * fix(stepfunctions): end an execution that spends its budget waiting A state machine's TimeoutSeconds budget was read only between states and around the two pauses a definition asks for, a Wait and a Retry backoff. Every other way a state blocks outlasted it: a Task waiting for its token, a states:startExecution.sync or ecs:runTask.sync poll, and a Parallel or Map waiting for its branches. Those executions ended past their budget, and ended FAILED or SUCCEEDED rather than TIMED_OUT. Each of those waits now stops at the budget, and the Task path publishes no failure event for the state it cuts. Measured against us-east-1: a state machine with TimeoutSeconds 5 over an activity Task whose own TimeoutSeconds is 60 stops at exactly 5.000 s with status TIMED_OUT, and its history is ExecutionStarted, TaskStateEntered, ActivityScheduled, ExecutionTimedOut, with no ActivityTimedOut and no ExecutionFailed. --------- Co-authored-by: Facundo Paredes <naranjax@MAC-69786.local> |
||
|
|
08e532ab1a |
feat(cloudformation): CDK Provider-framework custom resources and changeset/SSM param fidelity (#2688)
* feat(cloudformation): changeset diffs, stack params, SSM attributes CDK's deploy loop reads all three: DescribeChangeSet now returns computed Add/Modify/Remove resource changes instead of an empty list (an empty list makes CDK skip ExecuteChangeSet on updates), DescribeStacks echoes the stack's merged parameters, and AWS::SSM::Parameter resources expose Value/Type/Name attributes so Fn::GetAtt resolves the bootstrap version (cherry picked from commit 80ac80063e84ef1be977fe625334e722cc1ed8bb) * feat(cloudformation): resolve SSM-typed stack parameters AWS::SSM::Parameter::Value<String> template parameters resolve through SSM for the stack's account and region; missing parameters fail with the real ValidationError message. Landing Zone Accelerator's security and logging stacks depend on this typed-parameter resolution. The IAM password-policy and S3 replication-config changes from the same source commit ship separately in the iam and s3 branches. (cherry picked from commit 10dbabbf5e31d763a398fc1fff16ab0484958af0) * feat(cloudformation): drive CDK Provider framework custom resources The CDK Provider framework defers its ResponseURL callback to a Step Functions waiter that polls framework.isComplete on a Retry cadence until the resource is ready. The custom-resource provisioner only waited the synchronous single-lambda budget for a ResponseURL PUT, so the waiter-driven PUT never landed. A framework.onEvent ServiceToken is now awaited on a bounded async budget so that PUT is captured; onEvent-only and single-lambda resources are unchanged. The engine-side half of the original commit -- a Task-only Retry implementation for the ASL executor (ErrorEquals/IntervalSeconds/ MaxAttempts/BackoffRate/MaxDelaySeconds) -- is dropped here: upstream #2455 ("feat(sfn): support Retry policies in Task, Parallel, and Map states") landed a broader Retry implementation independently (Task, Parallel, and Map states; JitterStrategy; $$.State.RetryCount; Retry-before-Catch ordering), a strict superset of what this commit needed. The full stepfunctions suite (411 tests) is green against it on this branch, and CustomResourceProviderFrameworkTest (a hermetic test of the provisioner's own detect-and-wait logic, no Step Functions involved) is unaffected by the drop. (cherry picked from commit 5b3502d8c9dddf3766ca3f94fe7f146042dc00fd) * docs(cloudformation): document CDK provisioning Documents the CDK Provider-framework custom-resource support and folds its cross-reference into upstream's existing "Retry policies" section in step-functions.md rather than duplicating it with a separate "State Retry" section (upstream #2455 already documents the Retry engine itself). * feat(cloudformation): budget custom-resource waits by idleness, not total time The async custom-resource wait was a fixed 3-minute total budget. That is a property of the emulator, but the time a CDK provider-framework resource needs is a property of the work: Custom::CreateOrganizationAccounts creates exactly one account per 15s waiter poll, so a 3-account org finishes in ~45s while a 15-account org needs ~195s. Past the budget the Lambda is guillotined mid- success -- the accounts all exist, but the resource reports CREATE_FAILED, the stack rolls back, and CDK's readback then surfaces the misleading "NoStack: CloudFormationStack object does not hold a stack". Measure idleness instead. The provisioner already embeds its callback token in the ResponseURL it puts on every event, and the framework echoes that event into each framework.isComplete poll, so a poll arriving at LambdaService is proof of progress for a specific pending resource. Each poll resets the budget, which makes the wait proportional to the work without CloudFormation needing to know what the work is -- and a genuinely hung resource still fails after 3 idle minutes exactly as before. CustomResourceLiveness lives in core.common so the Lambda service can report progress without depending on CloudFormation; the dependency already runs the other way. (cherry picked from commit 14087c992ebb75d109999153a9e8af7e3c2d79f4) (cherry picked from commit 51349e4e017ed08d90e6e71212414e2f306c826b) * fix(cloudformation): call the caller-scoped getStackOrThrow overload that exists The changeset-diff commit re-derived onto main carried a call to a three-arg getStackOrThrow(name, region, accountId) overload that only existed on the account-scoping commit deliberately skipped as superseded by upstream. Upstream's resolveStack already scopes to the caller's account, so the two-arg form is equivalent and compiles. * fix(cloudformation): honour an arrived custom-resource response past its budget A synchronous custom-resource handler PUTs to the ResponseURL from inside the invoke the provisioner is blocked on, so its response can already be delivered by the time await() is entered. Two independent flaws then threw it away. The idle clock started at register(), before the invoke. A provider-framework onEvent-only handler that took 75s to return -- two nested cold container starts -- had spent its 10s CR_RESPONSE_TIMEOUT six times over before await was reached, so the very first deadline check was already negative. Idleness of the wait cannot include time the handler spent working; the clock now starts when the caller starts waiting. The deadline guard also threw without ever consulting the future, so a response that had completed it was discarded as a timeout. Observed on AccessAnalyzerServiceLinkedRoleCreateServiceLinkedRoleResource: the handler logged its response at 15:52:11.768 and the resource was failed 24ms later. An arrived response outranks the clock. Both are pinned by red-first tests. The existing idle-timeout guarantees are unchanged: nothing arriving still times out, and a resource that stops reporting liveness still dies on schedule from its last touch. (cherry picked from commit 7dc8bbca7d47b2a029b5656a89421a556b8296be) (cherry picked from commit 77b71b31a634ae27d7460a078b52dac250d67dc7) * refactor(cloudformation): extract Provider-framework detection from the provisioner The CDK Provider-framework `framework.onEvent` detection and the longer idle budget it earns lived in CloudFormationResourceProvisioner, adding ~55 lines to a class that is being dismantled rather than grown. Move the concern to ProviderFrameworkDetector: it owns the two waiter marker env vars, the best-effort environment probe, the 3-minute async budget and the test seam that shortens it. CustomResourceResponseStore — which already owns the idle-timeout concept via touch/await — gains an await overload that resolves the budget for a ServiceToken and delegates to the existing one, so the provisioner only passes the token through and appends the store's timeout detail to its error. Behaviour is unchanged. (cherry picked from commit 5f93439f409a32012a01b996c5edd0c29d23b260) * fix(stepfunctions): report custom-resource liveness on waiter polls A CDK provider-framework waiter's framework.isComplete poll is itself a Lambda Task the state machine invokes, so it goes through AslExecutor.invokeResource -> LambdaExecutorService directly, bypassing LambdaService.invoke() and the liveness hook it carries. A long-but- progressing custom resource's idle budget in CustomResourceResponseStore ticked down as if no polls were arriving, even while they kept landing. AslExecutor now reports liveness the same way LambdaService does: extract the callback token from the invoke payload and touch() it before invoking. * perf(core): avoid materializing the full payload string in tokenIn CustomResourceLiveness.tokenIn() ran on every Lambda invoke once liveness reporting is wired in, decoding the whole invoke payload as a UTF-8 String even though the overwhelming majority of invokes carry no callback URL at all. Scan the raw bytes for the ASCII "/cfn-response/" marker instead, and only allocate a String for the small token substring when one is found. * fix(cloudformation): compute accurate changeset resource diffs computeChangeSetChanges never read cs.getParameters(), so an update that only changed parameter values reported an empty diff and CDK skipped execution, leaving the old parameter-derived config deployed. It also diffed a SAM change set's raw template against the stack's expanded deployed template, reporting spurious Modify/Remove on every SAM-generated resource for a no-op update, and hardcoded Replacement=False even when a resource's Type changed. Now the diff expands a SAM change set's template before comparing, marks a resource Modify when it references a changed parameter, and reports Replacement=True when a resource's Type changes. * fix(cloudformation): restore last-successful parameters on update rollback executeTemplate overwrote the stack's live parameter map with an update's attempted values before resolving SSM-typed parameters, which can fail. A failed resolution rolled the stack back, but the update snapshot never captured parameters, so DescribeStacks reported the failed update's attempted values instead of the last successfully deployed ones. StackUpdateSnapshot now captures the stack's parameters alongside its template body, and rollbackFailedUpdate restores them together. * fix(cloudformation): log tolerated wait-slice timeouts in custom-resource poll loop Each slice of the custom-resource poll loop below the outer idle budget hit an intentionally-tolerated TimeoutException that was swallowed with only a comment, against the repo's convention of logging deliberately caught exceptions. * fix(cloudformation): honor Parameters.member.N.UsePreviousValue extractParameters never read UsePreviousValue, so submitting it without a ParameterValue stored an empty string for that key. The new parameter-diff logic in computeChangeSetChanges ( |
||
|
|
5600d21f32 |
feat(stepfunctions): emit task history events and chain previousEventId (#2703)
A Task state now emits Scheduled, Started, and Succeeded or Failed events. Service integrations get Task* events. Direct Lambda ARNs get LambdaFunction* events. Activity ARNs get Activity* events. taskScheduledEventDetails carries the resolved Parameters or Arguments as a JSON string. previousEventId now chains every event to the one before it. The first state's Entered event points to 0, matching real AWS. Details now include inputDetails and outputDetails where AWS has them. Event shapes were verified against real AWS. Fixes #2520 |
||
|
|
ff61c2b2a5 |
feat(stepfunctions): describe a distributed Map run after it finishes (#2694)
* feat(stepfunctions): describe a distributed Map run after it finishes DescribeMapRun was not implemented, and arn:aws:states:::aws-sdk:sfn:describeMapRun reached the end of the dispatch chain in invokeResource, so a distributed Map could not be inspected once it was over: the Map run ARN was minted from a fresh UUID, written into the S3 manifest, returned in the Map result and then dropped. A run is now retained where the ResultWriter mints that ARN, which is also the only place an ASL author reads it. The manifest is no shortcut to the counters, since it writes FAILED and PENDING as empty arrays and puts every item under SUCCEEDED, so the run carries the item count taken where the iterations complete. A Map fails on the first item that fails, so a retained run is one whose every item succeeded. That fixes the status, both tolerances and the redrive counters at the values us-east-1 reports for such a run, and leaves succeeded, total and resultsWritten as the item count. An unbounded Map, which ASL spells as MaxConcurrency 0 or by omitting it, is reported as Integer.MAX_VALUE. The Task integration recases the wire response rather than restating it, so the two renderings of a run cannot drift, and renders both dates as the SDK's ISO-8601. Closes #2671 * refactor(stepfunctions): close a Map run's window on the export that mints its ARN recordMapRun sampled the wall clock and then folded the child timings into both ends of the run's window, but the clock is read after MapIterationScheduler has joined every child and after applyResultWriter has exported, so it is at or past every child's stop. Math.max over the timings could therefore never move stop off that sample, and the javadoc promised a last-item stop the code never computed. The sampled value is the faithful one: AWS closes a Map run's window on the export rather than on the last item, and the sample is taken immediately after it. Only start is recovered from the timings, which is the one end the Map state records nowhere else. DescribeMapRun returns the same startDate and stopDate as before. * test(compatibility): cover DescribeMapRun through the AWS SFN SDK client StepFunctionsDescribeMapRunIntegrationTest only exercises the endpoint via RestAssured, leaving the SDK's own request serialization, endpoint routing and response deserialization untested, contrary to AGENTS.md's rule that management APIs be validated with AWS SDK clients. --------- Co-authored-by: Facundo Paredes <25681464+facuparedes@users.noreply.github.com> |
||
|
|
ea11e67719 |
fix(stepfunctions): fail the state when a JSONata expression returns nothing (#2689)
* fix(stepfunctions): fail the state when a JSONata expression returns nothing An expression that returned nothing lost its key and the execution carried on down the happy path. Real AWS fails the state with States.QueryEvaluationError, names the field the expression was written in and a Catch on that error fires. Three of the positions changed control flow rather than data: a Choice took Default, a Wait did not wait, and a Task sent its request with the argument omitted. evaluateField evaluates one expression and fails the state on a missing node. resolveTemplate calls it at every leaf, carrying the field it is inside and extending it with /key per object key and [i] per array index, so the cause names Output/a/b[0][1] the way AWS does. Choices[n]/Condition, Seconds, Error, Cause, MaxConcurrency and Items call it directly. Three pieces go with it, all of them things a missing node used to need. An undefined array element was a States.Runtime special case with its own wording; AWS answers States.QueryEvaluationError and Output/values[0], the same shape as every other position. resolveTemplateNode existed to let resolveTemplate turn a whole field that returned nothing into a null, so the output would still serialize; there is no output to serialize once the state fails. And the two ResultWriter guards fired only on a key resolveTemplate had dropped, which can no longer happen. An explicit JSON null is a value and still succeeds, everywhere. Closes #2665 * fix(stepfunctions): name a Choice rule's and a Catch clause's own fields under their index A matched Choices[i] rule and a matching Catch[i] clause carry their own Assign and Output, and applyJsonataAssignAndOutput named them 'Output' and 'Assign' as if they were the state's. AWS names them under the rule or the clause: Choices[1]/Output/v, Choices[0]/Assign/x and Catch[1]/Output/v, each measured on the account. The index is the position in Choices or Catch, not the position among the entries that matched. The Catch label was unobservable until now. doExecute calls handleCatch from inside its own catch (FailStateException), so an expression failure raised while resolving the clause's own Output escaped both that clause and its sibling catch (Exception), reaching the method-level handler that answers States.Runtime with the raw message. The execution now fails with the clause's own error, which is what AWS reports and what the clause was catching no longer is. * test(stepfunctions): follow the field path through the crashing evaluator stub * test(stepfunctions): put the Catch clause under test on a Task, as AWS requires aCatchClauseNamesItsOwnOutputUnderTheClauseIndex carried Catch on a Pass state, which AWS refuses: validate-state-machine-definition answers SCHEMA_VALIDATION_FAILED, "Field 'Catch' is not supported" at /States/Boom. The label the test pins is right, Catch[1]/Output/v, and the state now fails on its own Arguments the way the measured execution did, so the definition is one AWS accepts. * docs(stepfunctions): drop the deviation this change removes The key dropped by an expression that returned nothing is no longer Floci's own behaviour: the state fails, as the section below records. --------- Co-authored-by: Facundo Paredes <25681464+facuparedes@users.noreply.github.com> |
||
|
|
5534460492 |
fix(stepfunctions)!: reject JSONata top-level references at definition time (#2699)
* fix(stepfunctions)!: reject JSONata top-level references at definition time
A Step Functions JSONata expression is evaluated with no context item: the
execution input arrives as $states.input and an Assign variable as $name. A
path whose first step is a bare name reads a context item that does not exist,
and real AWS refuses the definition from CreateStateMachine,
UpdateStateMachine and ValidateStateMachineDefinition with
UNSUPPORTED_JSONATA_EXPRESSION: Reference to '<name>' at the top level is not
supported. Floci accepted those definitions and failed the execution instead.
Every JSONata string in a JSONata state is now walked before the state machine
is stored, and each distinct top-level name is reported with the message and
the /States/... location AWS prints. Only the first step of a path is read
against the top-level context, so later steps, predicates, sort terms and
group expressions stay legal; a lambda body keeps the defining context and is
walked. Syntax errors and $$ keep their current behaviour.
The parse tree of com.dashjoin:jsonata is package-private and Quarkus loads
application classes and dependency jars under different class loaders, so the
tree fields are read reflectively, resolved once at class initialization and
registered for native image.
BREAKING CHANGE: state machines whose JSONata expressions reference a bare
top-level name are now rejected at creation, as on AWS. Anchor the reference
with $states.input.<name> for input or $<name> for an Assign variable.
* fix(stepfunctions): parse a JSONata payload key named after an ASL field
The deny list of fields AWS does not parse as JSONata was applied to every
key at every depth, so a payload key named Next, Comment, Resource, Retry,
Default, ErrorEquals, Credentials, Branches, ItemProcessor or Iterator hid
its expression. AWS parses a payload whole: `Assign: {"Next": "{% phone %}"}`
and `Arguments: {"Payload": {"Comment": "{% phone %}"}}` are both refused
with `Reference to 'phone' at the top level is not supported.` The deny list
now stops applying once the walk enters Output, Assign, Arguments,
ItemSelector or BatchInput.
The same walk refused `ItemReader.ReaderConfig.CSVHeaders`, which holds
literal column names: `validate-state-machine-definition` returns OK for it
and `create-state-machine` stores the machine, so CSVHeaders joins the list.
---------
Co-authored-by: Facundo Paredes <25681464+facuparedes@users.noreply.github.com>
|
||
|
|
14112b8ace |
feat(stepfunctions): dispatch the seven Task service integrations of #2663 (#2686)
* feat(sfn): support the aws-sdk:sfn:startSyncExecution task integration Calling an Express child workflow from a Standard parent goes through arn:aws:states:::aws-sdk:sfn:startSyncExecution, which reached the end of the dispatch chain and failed with "Unsupported resource". The integration reuses the existing StartSyncExecution service call and differs from the optimized states:startExecution.sync integration in two observable ways: the response envelope uses PascalCase field names with Output as a JSON string, and a child execution that fails is reported through Status instead of failing the calling task. * feat(stepfunctions): dispatch the six remaining Task service integrations events:putEvents, aws-sdk:sfn:startExecution, aws-sdk:sfn:sendTaskSuccess, aws-sdk:sfn:sendTaskFailure, aws-sdk:scheduler:createSchedule and aws-sdk:scheduler:updateSchedule reached the end of the dispatch chain in invokeResource and failed with "Unsupported resource", although Floci already serves all six APIs. Each branch maps the Task Arguments onto the client the direct call already goes through: putEvents onto EventBridgeHandler, and the scheduler pair onto the controller's own parse and SchedulerService. Two conventions of the aws-sdk: integrations, measured against us-east-1 through test-state, now hold for the whole family and correct the startSyncExecution envelope with them. A timestamp is the SDK's ISO-8601 rendering rather than the epoch seconds the wire response carries, and an error names the SDK exception class, so it always ends in Exception. SendTaskSuccess and SendTaskFailure report whether the token resolved a waiting task, which is what lets the Task integration fail with Sfn.InvalidTokenException instead of reporting a delivery that never happened. The direct API keeps tolerating an unknown token. Closes #2663 * fix(stepfunctions): make scheduler argument validation reachable for Retry and Catch parseScheduleRequest raises the same AwsException the scheduler service raises, so a Task whose Target.EventBridgeParameters is incomplete failed the execution with States.Runtime and skipped the state's Catch. It now runs inside the same translation as the service call and fails with Scheduler.ValidationException. * fix(scheduler): answer a malformed EcsParameters list with ValidationException A CapacityProviderStrategy, PlacementConstraints, PlacementStrategy or Tags list holding anything but objects made ObjectMapper.convertValue raise IllegalArgumentException, which CreateSchedule and UpdateSchedule answered with a server error and the aws-sdk:scheduler Task integration turned into States.Runtime. The conversion failure is now named per field and carries the 400 the rest of the parser's validations carry. * fix(scheduler): answer a malformed awsvpcConfiguration list with ValidationException Subnets and SecurityGroups went through a bare ObjectMapper.convertValue, so an element that is not a string left the same unhandled IllegalArgumentException the EcsParameters object lists left. They now read through a stringList sibling of mapList and carry the parser's 400. * test(stepfunctions): pass the scheduler and eventbridge dependencies to the executor under test * fix(scheduler): refuse a scalar in an awsvpcConfiguration list instead of coercing it * fix(scheduler): refuse a non-list EcsParameters field instead of dropping it * test(stepfunctions): catch a malformed scheduler list as the SDK exception AWS sends --------- Co-authored-by: Facundo Paredes <naranjax@MAC-69786.local> Co-authored-by: Facundo Paredes <25681464+facuparedes@users.noreply.github.com> |
||
|
|
48e0ecd809 |
fix(stepfunctions): keep a JSONata expression's explicit null in the output (#2684)
* fix(stepfunctions): keep a JSONata expression's explicit null in the output
A JSONata expression evaluating to JSON null lost its key, exactly as an
expression that returned nothing did. Real AWS answers {"v":null} to
Output {"v":"{% null %}"} and keeps the null in a nested object, in an
array, in Assign and in a Task's Arguments.
dashjoin flattens JSONata's null marker into a Java null unless
outputConvertNulls is off, which made the two indistinguishable inside the
evaluator. With it off, $states and the workflow variables bind through
toJsonataValue so an input null stays a null the expression can see, the
result is walked back with the marker mapped to a JSON null and a Java null
mapped to a missing node, and resolveTemplate drops only the missing node.
Closes #2664
* fix(stepfunctions): resolve a whole JSONata field that returned nothing to a null
A MissingNode is how the evaluator says "this expression returned nothing", and
resolveTemplate handed it straight to the executor when the whole Output or
Arguments field was that one expression. exec.setOutput writes the state output
with toString(), and a MissingNode writes itself as the empty string, so
DescribeExecution answered "output": "" instead of JSON.
resolveTemplate is now the boundary and answers a JSON value: a whole field that
returned nothing is a null, which is what it was before the marker existed. The
recursion moves to the private resolveTemplateNode, where "returned nothing" is
still itself in the two positions that read it, an object field it drops and an
array element it fails the state on.
AWS fails such a state with States.QueryEvaluationError; that is #2665 and stays
open.
* test(stepfunctions): read $string() with no argument as nothing, not as null
* docs(stepfunctions): mark the key dropped by an expression that returned nothing as a deviation
---------
Co-authored-by: Facundo Paredes <25681464+facuparedes@users.noreply.github.com>
|
||
|
|
395401807b |
fix(stepfunctions): bound JSONata evaluation by time and depth (#2697)
JSONata evaluation ran unbounded. A recursive expression with no base case pinned a core and left the execution RUNNING for ever: the library optimises the tail call, so it loops rather than overflowing the stack and no Error ever reaches the executor. Deep non-tail recursion did throw, but a StackOverflowError the evaluator's catch cannot see. Bound each expression with Frame#setRuntimeBounds, which the library has and Floci never called. Either bound raises a JSONata error, so the existing catch turns it into States.QueryEvaluationError, and the state fails through the same path as any other evaluation error: catchable by Catch, retryable by Retry. Five seconds and 500 levels sit deliberately above AWS. Measured with test-state, AWS refuses a non-tail-recursive function at a nesting depth of 125 and accepts it at 95, and the widest sequence it accepts evaluates here in about 100 ms, so no expression AWS runs can reach either bound. Closes #2667 Co-authored-by: Facundo Paredes <25681464+facuparedes@users.noreply.github.com> |
||
|
|
2a7ee7a605 |
fix(stepfunctions): write a large whole number in full in $string (#2683)
$string switched to exponent notation at Long.MAX_VALUE, so $string(1e20) returned "1e+20" where AWS returns "100000000000000000000". AWS's boundary is 1e21, on both signs. The execution succeeds either way, so a $string used as a MessageGroupId, an S3 key or a DynamoDB key wrote a different key on each engine without either reporting an error. $string is now bound on the evaluation frame next to the six functions of the Step Functions dialect, with the library's own signature so every arity and type error stays what it was. Below the boundary a double is replaced by the exact integer of the shortest decimal that reads back as it, which is the digit string AWS prints; the library formats everything else. Closes #2669 Co-authored-by: Facundo Paredes <25681464+facuparedes@users.noreply.github.com> |
||
|
|
eb5134da2d |
feat(stepfunctions): add the JSONata functions of the Step Functions dialect (#2676)
Step Functions extends JSONata with $parse, $partition, $range, $hash, $random and $uuid. None of them exist in the JSONata language, so an expression calling one failed with "Attempted to invoke a non-function" and the execution failed with States.QueryEvaluationError. Bind the six on the evaluation frame next to $states and the workflow variables. Behaviour follows AWS on the cases a naive reading gets wrong: a non-integer argument rounds towards zero, several argument combinations evaluate to undefined instead of failing, $range collapses a single-element range to a bare number, $parse rejects the JSON AWS rejects, and $random(seed) reproduces java.util.Random. Verified with a 65-expression differential against real AWS Step Functions: 65 match, 0 differ. Co-authored-by: Facundo Paredes <25681464+facuparedes@users.noreply.github.com> |
||
|
|
b6418dbfee |
feat(sfn): support mocked service integrations (SFN_MOCK_CONFIG) (#2452)
* feat(sfn): support mocked service integrations (SFN_MOCK_CONFIG) StartExecution accepts a state machine ARN with a test case suffix in the Step Functions Local format. The test case comes from the mock configuration file named by SFN_MOCK_CONFIG. A mocked Task state returns the configured Return payload or fails with the configured Throw error instead of calling the integrated service. The mocked error and cause reach Retry and Catch unchanged. States not named in the test case still call their real integration, so mocked and real calls combine in one execution. Behavior was verified against Step Functions Local 2.0.0. Closes #2283 * fix(sfn): never retry or catch States.Runtime even when named explicitly * fix(sfn): keep a bare trailing '#' unstripped on StartSyncExecution |
||
|
|
56e74d64c6 |
feat(sfn): support Retry policies in Task, Parallel, and Map states (#2455)
* feat(sfn): honor Retry policies in the ASL executor Task, Parallel, and Map states previously ignored their Retry field, so any failure went straight to Catch or failed the execution. They now retry per the ASL spec. ErrorEquals matching reuses the Catch matcher, including the States.ALL and States.TaskFailed wildcards, and States.Runtime is never retried. AWS defaults apply when fields are omitted (MaxAttempts 3, IntervalSeconds 1, BackoffRate 2.0). MaxDelaySeconds is honored. Each retrier keeps its own attempt counter and an exhausted retrier falls through to Catch. The context object field $$.State.RetryCount increments per attempt. Attempt counts, defaults, backoff timing, retry before catch order, and per attempt RetryCount resolution were verified against real AWS Step Functions in us-east-1 using execution histories. Two deviations are documented. The delay between attempts is capped at 30 seconds, matching the cap Floci applies to Wait states. JitterStrategy is accepted but ignored. Refs #2283 * test(sfn): add end-to-end Retry integration tests Covers the JSON 1.0 wire protocol path. The fail-then-succeed case works without mocks by resolving the DynamoDB table name from $$.State.RetryCount, so attempt 0 targets a missing table and the retry targets one that exists. This also exercises per attempt Parameters re-resolution, which real AWS does the same way. The other cases cover retrier exhaustion falling through to Catch and an unmatched error failing without retry. * fix(sfn): unwrap branch failures so Parallel Retry and Catch apply * fix(sfn): isolate the context object per Parallel branch and per branch state * fix(sfn): fail a missing Lambda function as Lambda.ResourceNotFoundException * test(sfn): cover Retry and Catch for Parallel and Map states * feat(sfn): support JitterStrategy FULL in Retry backoff * fix(sfn): keep branch Error causes wrapped so executions still terminate |
||
|
|
97ac3cabb5 |
feat(stepfunctions): add UpdateStateMachine and update in place on stack updates (#1867)
* feat(stepfunctions): add UpdateStateMachine and update in place on stack updates * test(dynamodb): retain Quarkus port for cleanup * chore: rerun CI after download outage * fix(cloudformation): preserve log group on failed rename * fix(cloudformation): scope update rollback to attempted resources * fix(cloudformation): delete resources after stack updates * test(cloudformation): wire cloudfront fixture dependency * fix: include Step Functions update date in describe response * fix: preserve Step Functions describe response shape * fix: preserve generated Step Functions names |
||
|
|
a7da1b9856 |
feat(stepfunctions): run Map iterations concurrently honoring MaxConcurrency (#1810)
* feat(stepfunctions): run Map iterations concurrently honoring MaxConcurrency A Map state ran its iterations one after another. AWS runs them concurrently up to MaxConcurrency (default 0 = unlimited), which is a correctness requirement, not just a speed-up: a Map whose iterations coordinate — e.g. a dependency-ordered fan-out where one child blocks until a sibling completes — deadlocks when the iterations are serialised. Run each iteration on the shared executor under the execution's account, gated by a Semaphore sized to MaxConcurrency (unlimited when 0). Results are written into per-index slots so the output array preserves input order regardless of completion order, MaxConcurrency=1 stays strictly sequential, and a failed iteration cancels the rest and fails the Map (fail-fast, matching the default ToleratedFailureCount of 0). * fix(stepfunctions): cap Map worker threads with a bounded pool + handle interruption Address review: submitting every iteration to the shared cached pool behind a Semaphore spawned one thread per item (a 1000-item Map with MaxConcurrency=5 created ~1000 threads, ~995 parked). Run iterations on a fixed-size per-Map ThreadPoolExecutor sized to MaxConcurrency so live threads are capped and the rest queue. shutdownNow() in finally stops the iterations on any exit, and an InterruptedException from the driver now preserves the interrupt status. * fix(stepfunctions): make Map concurrency bounded and fail-fast * docs(stepfunctions): document map concurrency * test(dynamodb): retain Quarkus port for cleanup * chore: rerun CI after OpenTofu registry flake * test(stepfunctions): pin Map item selection order |
||
|
|
7d70f64162 |
feat(docs): generate Supported Actions tables from handler source (#1641)
* feat(docs): generate Supported Actions tables from handler source The "Supported Actions" tables in docs/services/*.md were hand-maintained and drifted from the handlers. For example secrets-manager.md omitted RestoreSecret, which SecretsManagerJsonHandler dispatches, and acm.md listed RenewCertificate, which is not implemented anywhere in src/. Derive the action list from handler source so it cannot drift, while keeping the hand-written Description column: - tools/docs/regen_action_docs.py extracts actions from `case "X" ->` switch arms (including multi-label arms) and JAX-RS REST controllers, and rewrites only the rows between the <!-- floci:actions --> markers. Descriptions are preserved by action name; new actions get a "-" placeholder. PascalCase-only matching avoids picking up SCREAMING_CASE labels from non-action switches. - tools/docs/services.yaml registers 18 single-table switch services and lists the remaining switch handlers under deferred_handlers, so the new-service sentinel fires only on a genuinely unregistered handler. - make docs-sync / docs-check / docs-test, plus a Python-only CI workflow that gates on handler, doc, and tooling changes. - Migrate 18 service docs into marker blocks, reconciling real drift (adds RestoreSecret, ImportCertificate, and others; drops the unimplemented RenewCertificate). Revives the parser and CI gate from #738 by @ericbsantana and completes the description-preservation its spec described. REST-mode, mixed-mode, multi-table, non-tabular, S3, and ecr docs are deferred and tracked in deferred_handlers. * docs: drop standalone design spec from action-docs tooling Remove ideas/auto-generated-action-tables.spec.md and the four references to it (CONTRIBUTING.md, Makefile, regen_action_docs.py docstring, services.yaml). It was a planning artifact; the operational docs live in CONTRIBUTING.md and the tooling is self-documenting. The #738 / @ericbsantana credit is preserved in the PR description. * chore: address review on action-docs tooling - pin actions/checkout to v7.0.0 in docs-actions workflow to match the repo-wide bump (#1690), so dependabot does not immediately flag the new file - document in the generator docstring that a switch case label counts as supported purely by existing, so a per-action UnsupportedOperation stub would be a false positive (handlers here reject from the default arm) * docs: regenerate action tables against current handler source Resync the generated Supported Actions tables to handler source after rebasing onto the latest main: - cloudformation: add DescribeStackInstance and DescribeStackSetOperation now emitted by the handler, and keep the implemented StackSet descriptions - cloudtrail: add LookupEvents - firehose: add UpdateDestination - step-functions: add PublishStateMachineVersion, ListStateMachineVersions, DeleteStateMachineVersion - register the cloudcontrol handler in deferred_handlers so the strict unregistered-handler gate passes (no standalone action table yet) * fix(docs): prevent action-table generator from silently dropping actions Address the latest review pass on the action-docs tooling: - switch extraction now captures case arms whose labels wrap across lines (valid Java 14+ syntax). The capture group excludes only `{ } ;` boundaries, so it spans newlines between labels but stops at the arm's `->`. A wrapped arm was previously missed, and docs-check would stay green because the doc and the generated output agreed on the omission, defeating the whole drift-prevention guarantee. - REST extraction skips Javadoc / inline comments between a verb annotation and the method signature; such a line otherwise reset the lookahead and dropped the action. - parse_marker_block raises a descriptive error when a marker is not on its own line, instead of a bare "substring not found". - doc, source, and registry reads/writes are pinned to UTF-8 so generation is locale-independent (the docs contain non-ASCII text). - the docs-actions push trigger watches Makefile and the workflow file, matching its pull_request trigger. Adds regression tests for the multi-line arm and comment-skip paths (20 total). |
||
|
|
cf0db6edc9 |
add ValidateStateMachineDefinition action (#845)
* add ValidateStateMachineDefinition action * populate diagnostic.location with /States/<state>/<field> * addressed review |
||
|
|
9e35046647 |
Docs/enviroment instead yml (#764)
* docs: moving all config to env instead of yml * docs: sync with main and new features * docs: reverting docker-compose.yml |
||
|
|
a32b7f1f3b |
docs: comprehensive audit sweep + CHANGELOG backfill (1.1.0-1.5.2) (#326)
CHANGELOG.md was empty for the 1.1.0-1.5.2 release cycle and service docs had drifted from code behaviour. This sweep reconciles docs against the current codebase on upstream/main. - Backfill CHANGELOG.md for 1.1.0 through 1.5.2 from git history - Correct exact operation counts in docs/services/index.md: S3 (~30 -> 58), Lambda (~25 -> 30), API Gateway v1 (~24 -> 62). Counts now come from the actual dispatch handlers rather than @Path annotation counts. - Rewrite README "Supported Services" table to drop per-service op counts (they drift too fast); point readers at docs/services/index.md - Update 24 service docs for accuracy, add "Not Implemented" sections where relevant (s3.md, lambda.md, api-gateway.md) - Refresh configuration and getting-started docs - Add EventBridge Scheduler and AppConfig to mkdocs nav - Add AppConfig / AppConfigData rows to README and services index following the 1.5.2 upstream release |
||
|
|
61433f59ab | firt commit |