Skip to content

decode_setup() doesn't forward the group end-tag argument #2148

@klon

Description

@klon

protobufjs 7.5.5 and 8.0.1 has a bug where decode_setup(), the lazy-initialization wrapper for .decode() only forwards (reader, length) but not the third e (end-tag) argument. This means on the first decode call for any type, proto2 group end markers (wire type 4) aren't recognized, causing an "invalid wire type 4" error.

There is a workaround, pre-calling setup() on every type avoids hitting decode_setup at runtime.

function setupAllTypes(ns: protobufjs.NamespaceBase) {
  if (ns instanceof protobufjs.Type) {
    ns.setup();
  }
  for (const nested of ns.nestedArray) {
    if (nested instanceof protobufjs.Namespace) {
      setupAllTypes(nested);
    }
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions