elsa-workflows/elsa-core · error · InvalidDataException
Unexpected end of protobuf payload.
Error message
Unexpected end of protobuf payload.
What it means
ReadVarint decodes at most 10 continuation bytes of a base-128 varint. If the remaining buffer empties before a terminating byte (high bit clear) is found, the payload is truncated, and the parser throws InvalidDataException with this message.
Solutions
- Ensure the full request body is sent (check Content-Length vs actual bytes, disable body-buffering limits on proxies).
- Re-send the export; truncation is usually transient network/proxy behavior.
- If reproducible, capture the raw body and validate it with a protobuf decoder to find where truncation starts.
Defensive patterns
Strategy: retry
Validate before calling
if (bytes.Length < 2 || bytes[^1] != 0) // heuristic: incomplete final varint
logger.LogWarning("OTLP payload appears truncated; not sending."); Try / catch
try { await SendAsync(body); }
catch (InvalidDataException ex) when (ex.Message.Contains("Unexpected end"))
{ logger.LogWarning(ex, "OTLP payload truncated in transit; retrying full export."); } Prevention
- Verify proxy/load balancer body limits and timeouts allow full OTLP export bodies.
- Keep export batches small so a single request is less likely to be cut off.
When it happens
Trigger: A truncated OTLP protobuf payload ends mid-varint: the request body was cut off by a proxy timeout, Content-Length mismatch, or partial write, so the last field header/length varint never completes.
Common situations: Reverse proxy or load balancer buffering limits cutting large exports; exporter retry after connection reset leaves partial bytes; testing with hand-crafted byte arrays that are too short.
Understand the failure class
Background: "cannot parse invalid wire-format data", "cannot unmarshal", "failed unmarshalling": protobuf unmarshal errors explained — this error's family across 10 libraries.
Related errors
- Unsupported protobuf wire type
- Invalid protobuf varint.
- The OTLP timestamp is outside the supported range.
- OpenTelemetry gRPC ingestion is enabled, but no gRPC…
- RequestBodyTooLargeException
AI-assisted analysis of elsa-workflows/elsa-core@fe9217bdfa (2026-09-13).
Data as JSON: /api/errors/878cf2bfc477a229.
Report an issue: GitHub.
Appendix: source
Thrown at src/modules/Elsa.Diagnostics.OpenTelemetry/Ingestion/HttpProtobuf/OtlpHttpProtobufParser.cs:680
case ProtobufWireType.Fixed32:
EnsureAvailable(4);
_remaining = _remaining[4..];
field = new ProtobufField(number, wireType, default, default, default);
return true;
default:
throw new InvalidDataException($"Unsupported protobuf wire type '{wireType}'.");
}
}
private ulong ReadVarint()
{
ulong value = 0;
var shift = 0;
for (var i = 0; i < 10; i++)
{
if (_remaining.IsEmpty)
throw new InvalidDataException("Unexpected end of protobuf payload.");
var b = _remaining[0];
_remaining = _remaining[1..];
value |= (ulong)(b & 0x7f) << shift;
if ((b & 0x80) == 0)
return value;
shift += 7;
}
throw new InvalidDataException("Invalid protobuf varint.");
}
private readonly void EnsureAvailable(int byteCount)
{
if (_remaining.Length < byteCount)
throw new InvalidDataException("Unexpected end of protobuf payload.");View on GitHub (pinned to fe9217bdfa)