Files
floci/src/main/java/io/github/hectorvent
sheldon-nadarajah-sft 151e3fcc7a fix(lambda): round-trip StartingPosition on event source mappings (#2370)
* fix(lambda): round-trip StartingPosition on event source mappings

CreateEventSourceMapping accepted StartingPosition and StartingPositionTimestamp
but never stored them, so GetEventSourceMapping, ListEventSourceMappings and the
create response all omitted the fields entirely.

Any IaC tool that refreshes a mapping therefore reads the starting position back
as unset. Both fields are ForceNew in Terraform's aws_lambda_event_source_mapping,
so every plan proposes adding the value it already asked for and destroys and
recreates the mapping - on every single apply, indefinitely.

Store both on the mapping and emit them from buildEsmResponse, omitting them
when unset the way AWS does for sources that have no starting position. Absent
stays absent on the way in too: AWS requires a starting position for stream
sources, but Floci has always accepted mappings without one, so the new
validation only checks what a caller actually sent. There is no update path
because UpdateEventSourceMapping does not accept the field.

Also pass both through the CloudFormation provisioner, which dropped them for
the same reason.

* fix(lambda): surface a clear error on a malformed StartingPositionTimestamp

Addresses review feedback on the previous commit: silently dropping an
unparseable StartingPositionTimestamp let a bad CloudFormation template value
disappear into the generic "StartingPositionTimestamp is required" error,
pointing at the wrong problem and hiding the value that actually failed.

* test(cloudformation): cover StartingPosition through the CFN provisioner

Addresses review feedback: the existing ESM CFN test only exercises SQS
without a starting position, so nothing verified StartingPosition/
StartingPositionTimestamp actually survives provisionLambdaEventSourceMapping
rather than only the direct API path EsmIntegrationTest already covers.

* fix(cloudformation): reject non-finite StartingPositionTimestamp values

Double.parseDouble accepts "NaN"/"Infinity"/"-Infinity" without throwing,
so those slipped past the existing NumberFormatException catch and were
later rounded by LambdaService into epoch-zero or long-extremum
timestamps instead of being rejected.
2026-08-18 09:48:43 -04:00
..