www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - protobuf error: Tag value out of range

reply zoujiaqing <zoujiaqing gmail.com> writes:
code:
```d
auto req = new ApplyContact();
data.fromProtobuf!ApplyContact(req);
```

protobuf:

```d
class ApplyContact
{
      Proto(1) string fromId = protoDefaultValue!string;
      Proto(2) string toId = protoDefaultValue!string;
      Proto(3) string message = protoDefaultValue!string;
      Proto(4) string chatId = protoDefaultValue!string;
      Proto(5) ulong timestamp = protoDefaultValue!ulong;
      Proto(6) ContactApplySrc src = 
protoDefaultValue!ContactApplySrc;
      Proto(7) uint tagId = protoDefaultValue!uint;
}
```

log:
```log
2023-Oct-16 19:28:51.7708915 | 2772099 | warning | execute | 
google.protobuf.common.ProtobufException /root/.dub/packages/protobuf-0.6.2/protobuf/src/google/proto
uf/internal.d(199): Tag value out of range
----------------
/usr/include/dmd/phobos/std/exception.d:515 pure  safe void 
std.exception.bailOut!(google.protobuf.common.ProtobufException).bailOu
(immutable(char)[], ulong, scope const(char)[]) [0x56522c393626]
/usr/include/dmd/phobos/std/exception.d:436 pure  safe bool 
std.exception.enforce!(google.protobuf.common.ProtobufException).enforce!
bool).enforce(bool, lazy const(char)[], immutable(char)[], ulong)
[0x56522c3935a2]
/root/.dub/packages/protobuf-0.6.2/protobuf/src/google/protobuf/internal.d:199
pure  safe std.typecons.Tuple!(uint, "tag", google.protobuf.internal.WireType,
"wireType").Tuple google.protobuf.internal.decodeTag!(ubyte[]).decodeTag(ref
ubyte[]) [0x56522c5296ec]
/root/.dub/packages/protobuf-0.6.2/protobuf/src/google/protobuf/decoding.d:192
pure privchat.protocol.contacts.ApplyContact
google.protobuf.decoding.fromProtobuf!(privchat.protocol.contacts.ApplyContact,
ubyte[]).fromProtobuf(ref ubyte[], privchat.protocol.contacts.ApplyContact)
[0x56522c535c58]
source/executor/friend/ApplyFriendExecutor.d:23 void 
executor.friend.ApplyContactExecutor.ApplyContactExecutor.applyFriend(msgtrans.TransportConte
t.TransportContext, msgtrans.MessageBuffer.MessageBuffer) [0x56522c5cfdef]
/root/.dub/packages/hunt-reflection-0.2.1/hunt-reflection/source/witchcraft/
ixins/methods.d:160 const std.variant.VariantN!(32uL).VariantN
msgtrans.executor.AbstractExecutor.AbstractExecutor!(executor.friend.ApplyContactExecutor.ApplyContactExecutor).AbstractExecutor.__mixin3.__mixin8.MethodMixin!(executor.friend.ApplyContactExecutor.A
plyContactExecutor, "applyFriend",
0uL).MethodMixin.invoke(std.variant.VariantN!(32uL).VariantN,
std.variant.VariantN!(32uL).VariantN[]...) [0x56522c5a6d18]
/root/.dub/packages/hunt-reflection-0.2.1/hunt-reflection/source/witch
raft/invocable.d:90 const std.variant.VariantN!(32uL).VariantN
witchcraft.invocable.Invocable.invoke!(std.variant.VariantN!(32uL).VariantN,
Object, msgtrans.TransportContext.TransportContext,
msgtrans.MessageBuffer.MessageBuffer).invoke(Object,
msgtrans.TransportContext.TransportContext,
msgtrans.MessageBuffer.MessageBuffer) [0x56522d025a35]
/root/.dub/packages/msgtrans-0.1.4/msgtrans/source/msgtrans/execut
r/ExecutorInfo.d:73 nothrow void
msgtrans.executor.ExecutorInfo.ExecutorInfo.execute!().execute(ref
msgtrans.TransportContext.TransportContext,
msgtrans.MessageBuffer.MessageBuffer) [0x56522d02566f]
/root/.dub/packages/msgtrans-0.1.4/msgtrans/source/msgtrans/channel/tcp/Tc
ServerChannel.d:217 void
msgtrans.channel.tcp.TcpServerChannel.TcpServerChannel.dispatchMessage(hunt.net.Co
nection.Connection, msgtrans.MessageBuffer.MessageBuffer) [0x56522d0208b6]
/root/.dub/packages/msgtrans-0.1.4/msgtrans/source/msgtrans/channel/tcp/Tc
ServerChannel.d:150 hunt.io.channel.Common.DataHandleStatus
msgtrans.channel.tcp.TcpServerChannel.TcpServerChannel.initialize().__anonclass4.messageReceived(hunt.net.Co
nection.Connection, Object) [0x56522d020550]
/root/.dub/packages/msgtrans-0.1.4/msgtrans/source/msgtrans/channel/
cp/TcpDecoder.d:112 hunt.io.channel.Common.DataHandleStatus
msgtrans.channel.tcp.TcpDecoder.TcpDecoder.decode(hunt.io.By
eBuffer.ByteBuffer, hunt.net.Connection.Connection) [0x56522d035c61]
/root/.dub/packages/hunt-net-0.6.6/hunt-net/source/hunt/net/Abst
actConnection.d:178 hunt.io.channel.Common.DataHandleStatus
hunt.net.AbstractConnection.AbstractConnection.handleReceivedData(hunt.io.By
eBuffer.ByteBuffer) [0x56522d2776c0]
/root/.dub/packages/hunt-net-0.6.6/hunt-net/source/hunt/net/Abst
actConnection.d:159 hunt.io.channel.Common.DataHandleStatus
hunt.net.AbstractConnection.AbstractConnection.onDataReceived(hunt.io.By
eBuffer.ByteBuffer) [0x56522d2775eb]
/root/.dub/packages/hunt-1.7.13/hunt/source/hunt/io/channel/posix
AbstractStream.d:83 void
hunt.io.channel.posix.AbstractStream.AbstractStream.onDataReceived(hunt.io.By
eBuffer.ByteBuffer) [0x56522d3a362c]
/root/.dub/packages/hunt-1.7.13/hunt/source/hunt/io/channel/posix/
bstractStream.d:142 bool
hunt.io.channel.posix.AbstractStream.AbstractStream.tryRead() [0x56522d3a37ab]
/root/.dub/packages/hunt-1.7.13/hunt/source/hunt/io/TcpStream.d:428 void
hunt.io.TcpStream.TcpStream.onRead() [0x56522d3a23a0]
/root/.dub/packages/hunt-1.7.13/hunt/source/hunt/event/selector/Epoll.d:228
void hunt.event.selector.Epoll.AbstractSelector.handeChannelEvent(hunt.io.channel.AbstractChan
el.AbstractChannel, uint) [0x56522d39adcb]
/root/.dub/packages/hunt-1.7.13/hunt/source/hunt/event/selector/Epoll.d:173 int
hunt.event.selector.Epoll.AbstractSelector.doSelect(long) [0x56522d39ad14]
/root/.dub/packages/hunt-1.7.13/hunt/source/hunt/event/selector/Selector.d:195
void hunt.event.selector.Selector.Selector.onLoop(long) [0x56522d39b66a]
/root/.dub/packages/hunt-1.7.13/hunt/source/hunt/event/selector/Selector.d:155
void hunt.event.selector.Selector.Selector.doRun(void delegate())
[0x56522d39b574]
/root/.dub/packages/hunt-1.7.13/hunt/source/hunt/event/selector/Selector.d:120
nothrow void hunt.event.selector.Selector.Selector.runAsync(long, void
delegate()).__lambda3() [0x56522d39b4a7]
??:? void core.thread.Thread.run() [0x56522d3e80f9]
??:? thread_entryPoint [0x56522d43017b]
??:? [0x7fda50287ea6] | 
/root/.dub/packages/msgtrans-0.1.4/msgtrans/source/msgtrans/executor/ExecutorInfo.d:75
```
Oct 16 2023
parent zoujiaqing <zoujiaqing gmail.com> writes:
I was using a different version of dmd. Problem solved. thank you
Oct 16 2023