elsa-workflows/elsa-core · error · InvalidDataException

Unsupported protobuf wire type

Error message

Unsupported protobuf wire type '{wireType}'.

What it means

The hand-rolled OTLP protobuf parser reads a field tag, decodes the wire type, and switches on it. Protobuf defines wire types 0-5; any other wire type means the buffer is not a valid protobuf message, so the parser throws InvalidDataException naming the offending wire type.

Solutions

  1. Verify the exporter's protocol and content type are protobuf (application/x-protobuf) matching the HttpProtobuf endpoint.
  2. Validate the payload with a standard protobuf decoder to confirm it is well-formed before export.
  3. Point the exporter at the correct OTLP endpoint protocol (HTTP/protobuf vs gRPC) configured on the server.

Example fix

// before (curl test with wrong format)
curl -X POST $endpoint -H 'Content-Type: application/json' -d '{...}'

// after
OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf # exporter now sends application/x-protobuf
Defensive patterns

Strategy: validation

Validate before calling

if (!request.Headers.ContentType?.MediaType!.Equals("application/x-protobuf", StringComparison.OrdinalIgnoreCase) ?? true)
    return Results.StatusCode(StatusCodes.Status415UnsupportedMediaType);

Try / catch

try { ParseProtobuf(body); }
catch (InvalidDataException ex) { logger.LogWarning(ex, "Malformed OTLP protobuf payload rejected."); }

Prevention

When it happens

Trigger: Posting a body to the OTLP HTTP ingestion endpoint that is not valid protobuf encoding (e.g. JSON sent where content-type says protobuf), or a corrupted/truncated payload whose tag byte decodes to wire type > 5.

Common situations: Exporter misconfigured with wrong content type (application/json instead of application/x-protobuf); TLS/proxy corruption; sending a text body to the protobuf endpoint for testing with curl.

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


AI-assisted analysis of elsa-workflows/elsa-core@fe9217bdfa (2026-09-13). Data as JSON: /api/errors/df9538401fd534fa. Report an issue: GitHub.

Appendix: source

Thrown at src/modules/Elsa.Diagnostics.OpenTelemetry/Ingestion/HttpProtobuf/OtlpHttpProtobufParser.cs:668

                    EnsureAvailable(8);
                    var fixed64 = BinaryPrimitives.ReadUInt64LittleEndian(_remaining[..8]);
                    _remaining = _remaining[8..];
                    field = new ProtobufField(number, wireType, fixed64, default, BitConverter.Int64BitsToDouble((long)fixed64));
                    return true;
                case ProtobufWireType.LengthDelimited:
                    var length = checked((int)ReadVarint());
                    EnsureAvailable(length);
                    var bytes = _remaining[..length];
                    _remaining = _remaining[length..];
                    field = new ProtobufField(number, wireType, default, bytes, default);
                    return true;
                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)

View on GitHub (pinned to fe9217bdfa)