[release/9.0] Fix error adding log entry with no body #6762
+109
−3
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.
Backport of #6725 to release/9.0
/cc @JamesNK
Customer Impact
It is possible to send an OTEL log entry without a body. For example, a customer at #6703 configured OpenAPI instrumentation to not send a body. This caused an error in Aspire and the telemetry wasn't loaded.
Aspire assumes there is always a body and errors when attempting to access it and convert to the log entry message. The log entry won't be visible in Aspire.
The fix is to set the message to an empty string when there is no body present.
Note: One customer has raised this issue but it could be more widespead. Aspire doesn't give a notification that telemetry failed to load, it just won't be present in the UI.
Testing
Unit test.
Manual testing by creating OTLP log entry manually without body:
Risk
Low
Regression?
No
Microsoft Reviewers: Open in CodeFlow