NullPointerException from SnsInterceptor when publishing an SNS batch without a topic ARN
维护者通常 2 天内回复
还没有人认领这个 Issue。
评估
调研方向
检查 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 请求到达 SDK 的验证错误,而不是抛出 agent NPE 时,即表示完成。
由索引模型根据 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
- 派生
- 362
- 平均合并
- 3 天 18 小时
- 30 天内合并 PR
- 180
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
DataDog/dd-trace-java 的其他 Issue
-
Update DEFAULT_HTTP_CLIENT_ERROR_STATUSES to include 5xx status codes可能重新可做 关联的 PR 已关闭且未合并。 未关闭type: feature request
难度 1/5 1-3 小时 新手友好度 70/100
DataDog/dd-trace-java#10245 · 1 条评论 ·
维护者通常 2 天内回复
-
gRPC server instrumentations (grpc-1.5, armeria-grpc) don't make extracted W3C baggage current in the handler可能已有人在做 @mcculls 于 7 天前认领。 未关闭comp: context propagation inst: grpc type: feature request
难度 3/5 1-2 天 新手友好度 78/100
DataDog/dd-trace-java#12654 · 已指派 1 人 ·
维护者通常 2 天内回复
-
难度 4/5 3-5 天 新手友好度 62/100
DataDog/dd-trace-java#12608 ·
维护者通常 2 天内回复
-
type: bug report
难度 4/5 3-5 天 新手友好度 35/100
DataDog/dd-trace-java#12597 ·
维护者通常 2 天内回复
-
Queueing-time profiler aborts the whole instrumentation install under a JDK 24+ AOT cache (zero spans); disabling that one feature is enough可能已有人在做 @mcculls 于 14 天前认领。 未关闭
难度 4/5 3-5 天 新手友好度 35/100
DataDog/dd-trace-java#12540 · 5 条评论 · 已指派 1 人 ·
维护者通常 2 天内回复
查看 DataDog/dd-trace-java 的全部 Issue
相似的 Issue
-
[destination-snowflake] Custom domains rejected unlike source connections可能已有人在做 @kuza55 今天认领。 未关闭autoteam community connectors/destination/snowflake team/use
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 1 天内回复
-
area-dashboard
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 1 天内回复
-
component/operate kind/feature-request
难度 2/5 1-3 小时 新手友好度 85/100
维护者通常 1 天内回复
-
Forge coverage prompts carry text the agent cannot act on可能已有人在做 @graalvmbot 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 85/100
oracle/graalvm-reachability-metadata#10572 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 62/100
IBM/sample-app-mod#55 ·