Skip to content

pbjs: error when Enum contains negative number #609

@halex2005

Description

@halex2005

protobuf.js version: 6.4.0 (current master, 751a90f)

I have two files:

  1. ResolutionRequestInfo.proto
package SomeNamespace;

message ResolutionRequestInfo {
	optional ResolutionRequestType RequestType = 1 [default = UnknownResolutionRequestType];
}

enum ResolutionRequestType {
	UnknownResolutionRequestType = -1;
	Value1 = 1;
	Value2 = 2;
	Value3 = 3;
}
  1. and ResolutionRequestAttachment.proto
import "ResolutionRequestInfo.proto";

package SomeNamespace;

message ResolutionRequestAttachment {
    required ResolutionRequestType Type = 1;
}

when I call

./bin/pbjs -o ResolutionRequestAttachment.js -t static ResolutionRequestAttachment.proto

I got error:

/home/hal/git/protobuf.js/cli/pbjs.js:165
            throw err;
            ^

Error: unresolvable field type: ResolutionRequestType
    at Error (native)
    at Field.resolve (/home/hal/git/protobuf.js/src/field.js:242:19)
    at /home/hal/git/protobuf.js/cli/targets/static.js:236:15
    at Array.forEach (native)
    at buildType (/home/hal/git/protobuf.js/cli/targets/static.js:235:22)
    at buildNamespace (/home/hal/git/protobuf.js/cli/targets/static.js:120:9)
    at /home/hal/git/protobuf.js/cli/targets/static.js:137:13
    at Array.forEach (native)
    at buildNamespace (/home/hal/git/protobuf.js/cli/targets/static.js:133:20)
    at /home/hal/git/protobuf.js/cli/targets/static.js:137:13

When I set UnknownResolutionRequestType to positive value, pbjs generates js-file successfully

In v6.3.0 there was no such errors.

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