Skip to content

feat(kinesis): resolve stream name from StreamARN parameter#304

Merged
hectorvent merged 2 commits intofloci-io:mainfrom
hampsterx:feat/kinesis-arn-stream-addressing
Apr 10, 2026
Merged

feat(kinesis): resolve stream name from StreamARN parameter#304
hectorvent merged 2 commits intofloci-io:mainfrom
hampsterx:feat/kinesis-arn-stream-addressing

Conversation

@hampsterx
Copy link
Copy Markdown
Contributor

Summary

Most Kinesis actions now accept StreamARN as an alternative to StreamName, matching real AWS SDK behavior. When a client sends a full ARN (e.g. arn:aws:kinesis:us-east-1:123456789012:stream/my-stream), Floci extracts the stream name and resolves it normally.

  • Add shared resolveStreamName helper to KinesisJsonHandler that checks StreamName first, falls back to parsing StreamARN
  • Apply to 13 handler methods (all except CreateStream which only accepts StreamName per AWS API)
  • Refactor handleListShards from inline ARN logic to the shared helper
  • Guard against malformed ARNs (missing :stream/ segment, trailing slash, consumer ARNs)
  • Throw InvalidArgumentException when neither field is valid

Motivation

AWS SDKs send StreamARN when the user passes an ARN-format identifier. Libraries like async-kinesis detect the arn: prefix and use StreamARN automatically. Without this, Floci treats the entire ARN as a literal stream name and returns "Stream does not exist".

Test plan

  • 12 new unit tests (KinesisJsonHandlerTest) covering: StreamName resolution, StreamARN resolution, empty/whitespace name fallback, missing fields, malformed ARN, ARN ending in slash, consumer ARN extraction, StreamName precedence
  • 4 new integration tests (KinesisIntegrationTest): DescribeStream by ARN, PutRecord+GetShardIterator+GetRecords by ARN, missing field returns 400, malformed ARN returns 400
  • All existing tests unaffected (ListShards by ARN test continues to pass with refactored helper)
  • CI (requires Java 25)

Changes

 docs/services/kinesis.md                          |  12 ++
 .../services/kinesis/KinesisJsonHandler.java      |  65 ++++----
 .../services/kinesis/KinesisIntegrationTest.java  | 104 +++++++++++++
 .../services/kinesis/KinesisJsonHandlerTest.java  | 170 +++++++++++++++++++++
 4 files changed, 323 insertions(+), 28 deletions(-)

@fredpena fredpena added enhancement New feature or request kinesis labels Apr 9, 2026
Copy link
Copy Markdown
Collaborator

@hectorvent hectorvent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @hampsterx

@hectorvent
Copy link
Copy Markdown
Collaborator

Hi @hampsterx,

Please check internal test failure:

[INFO] Results:
[INFO] 
Error:  Failures: 
Error:    KinesisIntegrationTest.putAndGetRecordsByArn:160 1 expectation failed.
JSON path Records.size() doesn't match.
Expected: a value equal to or greater than <1>
  Actual: <0>

Most Kinesis actions now accept StreamARN as an alternative to
StreamName, matching real AWS behavior. A shared resolveStreamName
helper extracts the stream name from the ARN (guarding against
malformed and consumer ARNs) and throws InvalidArgumentException
when neither field is valid. handleListShards inline logic replaced
with the shared helper. CreateStream excluded (no ARN at creation).
…fter rebase

The putAndGetRecordsByArn test read from shardId-000000000000 which was
split by an earlier test, so GetRecords returned 0 records. Use a
dedicated 1-shard stream and tighten assertions. Renumber ARN test
orders (20-23) to avoid collision with upstream retention period tests.
@hampsterx hampsterx force-pushed the feat/kinesis-arn-stream-addressing branch from 85a093c to 8190130 Compare April 10, 2026 00:54
@hampsterx
Copy link
Copy Markdown
Contributor Author

fixed, tests failing due to #317 i think

@hectorvent hectorvent merged commit 202d6eb into floci-io:main Apr 10, 2026
9 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants