Skip to content

Fallback to application/octet-stream content type when for invalid UTF-8 message bodies so ServicePulse will not fail loading the BLOB#5394

Closed
ramonsmits wants to merge 2 commits intomasterfrom
fix-binary-body-content-type
Closed

Fallback to application/octet-stream content type when for invalid UTF-8 message bodies so ServicePulse will not fail loading the BLOB#5394
ramonsmits wants to merge 2 commits intomasterfrom
fix-binary-body-content-type

Conversation

@ramonsmits
Copy link
Member

@ramonsmits ramonsmits commented Mar 20, 2026

Summary

  • When a message body claims to be text (via content type header) but contains invalid UTF-8 bytes, the DecoderFallbackException handler now updates MessageMetadata["ContentType"] to application/octet-stream and falls back to body storage
  • Only ServiceControl's stored metadata is affected, the original NServiceBus message header is never modified

Impact on ServicePulse

  1. contentTypeParser.ts : application/octet-stream falls into the application/ branch but doesn't match +json or +xml, so it returns { isSupported: false }.
  2. BodyView.vue will show : "Message body cannot be displayed because content type application/octet-stream is not supported." This is an improvement over the current behavior where ServicePulse tries to parse binary data as JSON/XML and crashes.
  3. MessageStore.ts : the JSON/XML formatting try block won't trigger for application/octet-stream, so no parse errors.
  4. EditRetryDialog.vue : edit & retry will be disabled with a warning that the content type is not supported. Correct behavior for binary data.

…data

When a message body fails UTF-8 decoding despite the content type header
claiming text, update the metadata content type to application/octet-stream
and fall back to body storage instead of silently dropping the body.
@ramonsmits ramonsmits changed the title Fix content type metadata for invalid UTF-8 message bodies Fallback to application/octet-stream content type when for invalid UTF-8 message bodies so ServicePulse will not fail loading the BLOB Mar 20, 2026
When a failed message body is not valid UTF-8 despite the content type
header, update metadata and attachment content type to
application/octet-stream. Replay is unaffected as it uses the original
message headers, not metadata.
Comment on lines +56 to +57
contentType = "application/octet-stream";
processingAttempt.MessageMetadata["ContentType"] = contentType;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't feel right to do this at the RavenDB implementation.
We are about to add more persistences and it feels like this should be handled by the framework not the specific implementions

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@johnsimons if you look at this from the perspective of the bug fix and also that the content type handling is already in place it seems totally OK as a transitionary solution

@ramonsmits
Copy link
Member Author

@danielmarbach @johnsimons I have give it some more thought. I added this to mitigate strange behavior of what I thought was wrong. However, later I found the cause for that was the transport message mutator breaking the headers:

If the source states its json, but we cannot decode it.. that can have other reasons to. For example, it could be compressed and decompression is something that servicecontrol does not support while endpoints might.

@ramonsmits ramonsmits closed this Mar 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants