NullPointerException from SnsInterceptor when publishing an SNS batch without a topic ARN
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 25/100
Direzione di ricerca
Ispeziona i percorsi batch di v1 e v2 SnsInterceptor e i test esistenti “SNS message to phone number doesn't leak exception”. Esegui i task di test aws-java-sns-1.0 e aws-java-sns-2.0; il lavoro è completato quando una richiesta batch senza un topic ARN raggiunge l’errore di validazione dell’SDK invece di generare una NPE dell’agent.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- Java
- Stelle
- 737
- Fork
- 361
- Merge medio
- 3g 20h
- PR unite (30g)
- 173
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di DataDog/dd-trace-java
-
type: feature request
Difficoltà 1/5 1-3 ore Idoneità per principianti 70/100
DataDog/dd-trace-java#10245 · 1 commento ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 62/100
DataDog/dd-trace-java#12608 ·
-
type: bug report
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
DataDog/dd-trace-java#12597 ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
DataDog/dd-trace-java#12540 · 4 commenti · 1 assegnatario ·
-
comp: tooling type: bug report
DataDog/dd-trace-java#12469 · 1 reazione · 1 assegnatario ·
Tutte le issue di DataDog/dd-trace-java
Issue simili
-
certification
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 80/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
[BUG] ECR GetAuthorizationToken returns a proxyEndpoint for the default region, not the request's Apertabug ecr
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
Needs: Triage Type: Feature request
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
AntennaPod/AntennaPod#8794 ·
-
agentic-workflows
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
github/copilot-sdk#2760 ·