dotnet / aspire

Tools, templates, and packages to accelerate building observable, production-ready apps
https://learn.microsoft.com/dotnet/aspire
MIT License
3.91k stars 475 forks source link

[release/9.0] Fix error adding log entry with no body #6762

Open github-actions[bot] opened 8 hours ago

github-actions[bot] commented 8 hours ago

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 https://github.com/dotnet/aspire/issues/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:

image

Risk

Low

Regression?

No

Microsoft Reviewers: Open in CodeFlow