Decoding generic ErrorResponse

Currently using protobuf with ServiceStack inside my Angular application using protobufjs and everything is working great.

My only issue occurs when, for example, performing a delete operation and an exception is thrown and a generic ErrorResponse is returned. I don’t seem to be able to decode this protobuf data in my application. I’ve setup the appropriate .proto files etc but I’m getting an invalid wire type 7 error?

Any ideas?

Why aren’t you using JSON in a web application? It’s typically faster to use the browsers native JSON parser than a custom serialization library. What library are you using to deserialize the protobuf messages, it would need to deserialize the Error in the ErrorResponse DTO which is just a generic DTO containing a ResponseStatus property, e.g:

public class ErrorResponse : IHasResponseStatus
    [DataMember(Order = 1)]
    public ResponseStatus ResponseStatus { get; set; }

You can avoid using the generic ErrorResponse DTO by creating explicit Response DTOs which contain the ResponseStatus property, e.g:

class DeleteCustomer : IReturn<DeleteCustomerResponse> { ... }

class DeleteCustomerResponse
    public ResponseStatus ResponseStatus { get; set; }

Utilising protobuf because the application is transferring a lot of data between internal services, as well as to web browsers, and wanted the benefits.

Using the following library:

I have the following .proto file which I’m testing with:

syntax = "proto3";

message ResponseError {
  string errorCode = 1;
  string fieldName = 2;
  string message = 3;
  map<string, string> meta = 4;

message ResponseStatus {
  string errorCode = 1;
  string message = 2;
  string stackTrace = 3;
  repeated ResponseError errors = 4;
  map<string, string> meta = 5;

message ErrorResponse {
  ResponseStatus responseStatus = 1;

It seems to match the definitions in ServiceStack, but I’m still getting the error.

A further update, I’ve been using the tool at the following address to decode the protobuf data:

Once I’ve converted some ‘valid’ arraybuffer output to base64 and placed in that tool, I can see the various fields and data displayed. When I catch the subscribe error and place the err.error arraybuffer data into the tool I receive a wire error:

7B = field 15, type StartGroup

error: Invalid wire-type; this usually means you have over-written a file without truncating or setting the length; see

After many tests, it appears if you send over the appropriate Accept header for protobuf, this works fine.

If you request it via the query string ?format=x-protobuf, it doesn’t work correctly.

I hope this helps!

This may be resolved from the commit mentioned in this post, if it’s still an issue I’d need a stand-alone repro or failing test I can run locally to repro the issue.

All seems fine in 5.4.1. Thank you!

1 Like