Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

contrib/aws/aws-sdk-go-v2/aws: Fix streamName nil pointer panic #2846

Merged
merged 6 commits into from
Sep 12, 2024

Conversation

webdestroya
Copy link
Contributor

According to the AWS Kinesis API Docs:

When invoking this API, you must use either the StreamARN or the StreamName parameter, or both. It is recommended that you use the StreamARN input parameter when you invoke this API.

Currently, if requests use only the StreamARN parameter (as recommended by AWS), the streamName function will panic with a nil pointer.

I've updated the function to return the name first (if provided) to keep backwards compatibility. If that is nil, then it uses the resource part of the ARN. If that is nil, it returns empty string instead of panicking.

I added a second method coalesceNameOrArnResource (if you have a better name, let me know) to prevent having the code be copy/pasted for each switch member.

What does this PR do?

  • Fixes a nil pointer panic in aws streamName integration

Motivation

  • I'd rather my app not explode when publishing records

Reviewer's Checklist

  • Changed code has unit tests for its functionality at or near 100% coverage.
  • System-Tests covering this feature have been added and enabled with the va.b.c-dev version tag.
  • There is a benchmark for any new code, or changes to existing code.
  • If this interacts with the agent in a new way, a system test has been added.
  • Add an appropriate team label so this PR gets put in the right place for the release notes.
  • Non-trivial go.mod changes, e.g. adding new modules, are reviewed by @DataDog/dd-trace-go-guild.

According to the [AWS Kinesis API Docs](https://docs.aws.amazon.com/kinesis/latest/APIReference/API_PutRecords.html):

> When invoking this API, you must use either the StreamARN or the StreamName parameter, or both. It is recommended that you use the StreamARN input parameter when you invoke this API.

Currently, if requests use only the `StreamARN` parameter (as recommended by AWS), the `streamName` function will panic with a nil pointer.

I've updated the function to return the name first (if provided) to keep backwards compatibility. If that is nil, then it uses the resource part of the ARN. If that is nil, it returns empty string instead of panicking.

I added a second method `coalesceNameOrArnResource` (if you have a better name, let me know) to prevent having the code be copy/pasted for each switch member.
@webdestroya webdestroya requested review from a team as code owners September 7, 2024 02:01
Copy link
Contributor

@rarguelloF rarguelloF left a comment

Choose a reason for hiding this comment

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

LGTM, Thanks for fixing this issue!

@darccio darccio merged commit afcff94 into DataDog:main Sep 12, 2024
72 checks passed
nsrip-dd pushed a commit that referenced this pull request Sep 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants