Skip to content

System.Text.Json serialization limit hit when serializing large base64 document content #3501

@neharastogi

Description

@neharastogi

We're encountering System.Text.Json's 125MB serialization limit when working with FHIR resources that contain large base64-encoded document content.

Problem

The Firely SDK uses System.Text.Json for serialization and converts base64 byte arrays to strings. System.Text.Json has a hard limit on string value length during serialization, which causes failures when document content is large.

Background

System.Text.Json removed the base64 length limit for byte arrays in this PR: dotnet/runtime#85334

However, since the Firely SDK converts base64 bytes to strings before serialization, this fix doesn't apply. The string length limit still triggers.

We've added context about this issue affecting production workloads in the original System.Text.Json issue: dotnet/runtime#39953

Request

Could the SDK be updated to leverage the byte array serialization path (which no longer has the limit) rather than converting to strings? Or alternatively, is there another approach that would avoid hitting this limit?

Environment

  • Firely SDK version: 6.1.1
  • .NET version: 8

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels
    No fields configured for Enhancement.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions