Add correlation ID to exception messages and log on request initialization #1012
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.
Correlation IDs were not consistently logged during failures, making client-to-server log correlation difficult. Several exception paths lacked correlation ID context.
Changes
Exception Infrastructure
correlationIdfield and constructor toMsalExceptionbase classMsalClientException,MsalServiceException,MsalThrottlingExceptionLogHelper.createMessage()to embed correlation ID:[Correlation ID: {id}] {message}Exception Throw Sites Updated
Eight error paths now include correlation IDs from
RequestContext:HttpHelper)TokenRequestExecutor)AcquireTokenByAuthorizationGrantSupplier)AcquireTokenSilentSupplier)AbstractManagedIdentitySource,AcquireTokenByManagedIdentitySupplier)AcquireTokenByDeviceCodeFlowSupplier)InteractiveRequest)Request Initialization Logging
RequestContextconstructor now logs correlation ID on creation, ensuring every request ID is captured regardless of subsequent failure paths.Example
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
build.shibboleth.net/usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --enable-native-access=ALL-UNNAMED -classpath /usr/share/apache-maven-3.9.12/boot/plexus-classworlds-2.9.0.jar -Dclassworlds.conf=/usr/share/apache-maven-3.9.12/bin/m2.conf -Dmaven.home=/usr/share/apache-maven-3.9.12 -Dlibrary.jansi.path=/usr/share/apache-maven-3.9.12/lib/jansi-native -Dmaven.multiModuleProjectDirectory=/home/REDACTED/work/microsoft-authentication-library-for-java/microsoft-authentication-library-for-java org.codehaus.plexus.classworlds.launcher.Launcher -f pom.xml -B -V -e -Dfindbugs.skip -Dcheckstyle.skip -Dpmd.skip=true -Dspotbugs.skip -Denforcer.skip -Dmaven.javadoc.skip(dns block)login.windows.net/usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java -javaagent:/home/REDACTED/.m2/repository/org/jacoco/org.jacoco.agent/0.8.12/org.jacoco.agent-0.8.12-runtime.jar=destfile=/home/REDACTED/work/microsoft-authentication-library-for-java/microsoft-authentication-library-for-java/msal4j-sdk/target/jacoco.exec -noverify -jar /home/REDACTED/work/microsoft-authentication-library-for-java/microsoft-authentication-library-for-java/msal4j-sdk/target/surefire/surefirebooter-20260211220657743_3.jar /home/REDACTED/work/microsoft-authentication-library-for-java/microsoft-authentication-library-for-java/msal4j-sdk/target/surefire 2026-02-11T22-06-57_177-jvmRun1 surefire-20260211220657743_1tmp surefire_0-20260211220657743_2tmp(dns block)msidlabciam1.ciamlogin.com/usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java -javaagent:/home/REDACTED/.m2/repository/org/jacoco/org.jacoco.agent/0.8.12/org.jacoco.agent-0.8.12-runtime.jar=destfile=/home/REDACTED/work/microsoft-authentication-library-for-java/microsoft-authentication-library-for-java/msal4j-sdk/target/jacoco.exec -noverify -jar /home/REDACTED/work/microsoft-authentication-library-for-java/microsoft-authentication-library-for-java/msal4j-sdk/target/surefire/surefirebooter-20260211220657743_3.jar /home/REDACTED/work/microsoft-authentication-library-for-java/microsoft-authentication-library-for-java/msal4j-sdk/target/surefire 2026-02-11T22-06-57_177-jvmRun1 surefire-20260211220657743_1tmp surefire_0-20260211220657743_2tmp(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
💡 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.