NullPointerException from SnsInterceptor when publishing an SNS batch without a topic ARN
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 25/100
調査の方向性
v1 と v2 の SnsInterceptor の batch パスと、既存の「SNS message to phone number doesn't leak exception」テストを調査します。aws-java-sns-1.0 と aws-java-sns-2.0 のテストタスクを実行します。topic ARN を含まない batch リクエストが agent NPE をスローするのではなく、SDK の検証エラーに到達すれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Tracer Version(s)
1.66.0
Java Version(s)
25.0.2
JVM Vendor
Eclipse Adoptium / Temurin
Bug Report
SnsInterceptor derives the DSM topic name from the topic ARN. The single-publish path handles a missing ARN, because a publish to a phone number has neither topicArn nor targetArn:
String snsTopicArn = request.topicArn();
if (null == snsTopicArn) {
snsTopicArn = request.targetArn();
if (null == snsTopicArn) {
return context.request();
}
}
The batch path dereferences it straight away:
String snsTopicArn = request.topicArn();
String snsTopicName = snsTopicArn.substring(snsTopicArn.lastIndexOf(':') + 1);
PublishBatchRequest builds without a topic ARN, and the interceptor runs before marshalling, so a request that the SDK would have rejected with a validation error instead dies with an NPE thrown from the agent. Neither SDK wraps exceptions from modifyRequest (v2) or beforeMarshalling (v1), so it reaches the caller as-is:
java.lang.NullPointerException: Cannot invoke "String.lastIndexOf(int)" because "snsTopicArn" is null
at datadog.trace.instrumentation.aws.v2.sns.SnsInterceptor.modifyRequest
Both the v1 and v2 interceptors have it. I checked the other ARN parsing in the aws-java modules while I was there: AwsSdkClientDecorator guards it in v1 (if (null != topicArn)) and uses Optional.map in v2, so these two batch branches were the only unguarded ones.
Fix is up as #12457. It skips the injection and leaves the request alone, matching what the single-publish path already does. Tests mirror the existing SNS message to phone number doesn't leak exception case, and the aws-java-sns-1.0 and aws-java-sns-2.0 test tasks pass.
Filing this as an issue as well so it can be triaged and labelled. I can't set the inst:/type: labels on the PR myself.
Expected Behavior
A batch publish without a topic ARN should fail the way the SDK would fail it on its own, with a validation error. The agent should not turn it into an NPE.
Reproduction Code
SnsClient client = SnsClient.builder()
.endpointOverride(URI.create("http://localhost:4566"))
.region(Region.US_EAST_1)
.build();
client.publishBatch(PublishBatchRequest.builder()
.publishBatchRequestEntries(
PublishBatchRequestEntry.builder().id("1").message("hello").build())
.build());
With the agent attached this throws NullPointerException from SnsInterceptor. Without it, the SDK reports the missing topic.
- 主要言語
- Java
- スター
- 737
- フォーク
- 361
- 平均マージ
- 3日 20時間
- マージ済み PR(30日)
- 173
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
DataDog/dd-trace-java のほかの issue
-
type: feature request
難易度 1/5 1〜3時間 初心者へのやさしさ 70/100
DataDog/dd-trace-java#10245 · コメント 1 件 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 62/100
DataDog/dd-trace-java#12608 ·
-
type: bug report
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
DataDog/dd-trace-java#12597 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
DataDog/dd-trace-java#12540 · コメント 4 件 · 担当者 1 名 ·
-
comp: tooling type: bug report
DataDog/dd-trace-java#12469 · リアクション 1 件 · 担当者 1 名 ·
DataDog/dd-trace-java の issue をすべて見る
似ている issue
-
area/plugin
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
kestra-io/plugin-kestra#190 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
google-ai-edge/LiteRT-LM#3739 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
integra-team-red/meet-map#249 ·
-
[Studio][Bug] Cancelled create-user dialog keeps the password and admin switch for the next attempt オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
apache/rocketmq-dashboard#5064 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
wso2/dpdp-accelerator#287 ·