-
Notifications
You must be signed in to change notification settings - Fork 208
Fix exception message handling to prevent empty message field in Application Insights telemetry #4310
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
Closed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Co-authored-by: trask <[email protected]>
Co-authored-by: trask <[email protected]>
Copilot
AI
changed the title
[WIP] Exception without message fails to send to Application Insights
Fix exception message handling to prevent empty message field in Application Insights telemetry
Jul 13, 2025
Copilot finished work on behalf of
trask
July 13, 2025 02:19
trask
reviewed
Jul 13, 2025
...src/main/java/com/microsoft/applicationinsights/agent/internal/classicsdk/TelemetryUtil.java
Outdated
Show resolved
Hide resolved
Co-authored-by: trask <[email protected]>
Copilot finished work on behalf of
trask
July 13, 2025 02:39
Member
|
add a new smoke test to try to reproduce the reported issue |
Co-authored-by: trask <[email protected]>
Contributor
Author
Added new smoke test |
Copilot finished work on behalf of
trask
July 13, 2025 02:56
trask
reviewed
Jul 13, 2025
...ageHandling/src/main/java/com/microsoft/applicationinsights/smoketestapp/TestController.java
Show resolved
Hide resolved
…ge handling Co-authored-by: trask <[email protected]>
Co-authored-by: trask <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
Applications were experiencing telemetry failures when exceptions without messages (like
new NullPointerException()) were sent to Application Insights. The service would reject these with a 206 error:Root Cause
While the existing logic in
TelemetryUtil.javacorrectly set exception messages to the class name when null or empty, there was a potential edge case where the message field could still end up empty during the telemetry processing pipeline.Solution
Added a defensive check to ensure exception messages are never null or empty:
Changes Made
Testing
TelemetryUtilTestwith comprehensive test cases for various exception message scenariosExceptionMessageBehaviorTestto verify specific edge casesThis fix ensures that exceptions like
new NullPointerException()will have their message field set to the class name ("java.lang.NullPointerException") rather than being empty, preventing the 206 rejection from Application Insights.Fixes #4283.
Warning
Firewall rules blocked me from connecting to one or more addresses
I tried to connect to the following addresses, but was blocked by firewall rules:
123.com/usr/lib/jvm/temurin-17-jdk-amd64/bin/java -Dorg.gradle.internal.worker.tmpdir=/home/REDACTED/work/ApplicationInsights-Java/ApplicationInsights-Java/agent/agent-tooling/build/tmp/test/work @/home/REDACTED/.gradle/.tmp/gradle-worker-classpath2720992848603163633txt -Xmx512m -Dfile.encoding=UTF-8 -Duser.country -Duser.language=en -Duser.variant -ea worker.org.gradle.process.internal.worker.GradleWorkerMain 'Gradle Test Executor 5'(dns block)/usr/lib/jvm/temurin-17-jdk-amd64/bin/java -Dorg.gradle.internal.worker.tmpdir=/home/REDACTED/work/ApplicationInsights-Java/ApplicationInsights-Java/agent/agent-tooling/build/tmp/test/work @/home/REDACTED/.gradle/.tmp/gradle-worker-classpath8599791293474589709txt -Xmx512m -Dfile.encoding=UTF-8 -Duser.country -Duser.language=en -Duser.variant -ea worker.org.gradle.process.internal.worker.GradleWorkerMain 'Gradle Test Executor 15'(dns block)If you need me to access, download, or install something from one of these locations, you can either:
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.