-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Description
After release of version v7.5.2, our unit and system tests on Node BigQuery Storage library started to fail. I tested with multiple versions and it works just fine from 7.2.4 to 7.5.1 and fails with 7.5.2. Sounds like this PR might be causing the issue: #2068
I saw @sofisl trying to revert this PR on https://github.com/protobufjs/protobuf.js/compare/revert-2068-resolve-fix, but no release was cut with that. There is any plans to rollback this behavior ? I'm still investigating how to fix in the protobuf lib. It seems to be parsing the proto descriptor correct as a Type
, but when trying to encode into a protobuf binary, it fails.
More repro scenarios can be seen in the bigquery storage repo: https://github.com/googleapis/nodejs-bigquery-storage/blob/21122f5901fd5b6670c4a3271045a9b3828b7f6b/test/adapt/proto.ts#L198
minimal repro extracted from the BigQuery Node library:
const assert = require('assert');
const protobuf = require('protobufjs');
const protos = require('./protos/protos');
require('protobufjs/ext/descriptor');
const FieldDescriptorProto = protos.google.protobuf.FieldDescriptorProto;
const {Type} = protobuf;
const protoDescriptor = {
name: 'Nested',
field: [
{
name: 'record_id',
number: 1,
label: FieldDescriptorProto.Label.LABEL_OPTIONAL,
type: FieldDescriptorProto.Type.TYPE_INT64,
options: {},
},
{
name: 'recordDetails',
number: 2,
label: FieldDescriptorProto.Label.LABEL_REPEATED,
type: FieldDescriptorProto.Type.TYPE_MESSAGE,
typeName: 'Nested_recordDetails',
},
{
name: 'metadata',
number: 3,
label: FieldDescriptorProto.Label.LABEL_OPTIONAL,
type: FieldDescriptorProto.Type.TYPE_MESSAGE,
typeName: 'Nested_metadata',
},
],
nestedType: [
{
name: 'Nested_recordDetails',
field: [
{
name: 'key',
number: 1,
label: FieldDescriptorProto.Label.LABEL_REQUIRED,
type: FieldDescriptorProto.Type.TYPE_STRING,
options: {},
},
{
name: 'value',
number: 2,
label: FieldDescriptorProto.Label.LABEL_OPTIONAL,
type: FieldDescriptorProto.Type.TYPE_STRING,
options: {},
},
],
},
{
name: 'Nested_metadata',
field: [
{
name: 'createdAt',
number: 1,
label: FieldDescriptorProto.Label.LABEL_REQUIRED,
type: FieldDescriptorProto.Type.TYPE_INT64,
options: {},
},
{
name: 'updatedAt',
number: 2,
label: FieldDescriptorProto.Label.LABEL_OPTIONAL,
type: FieldDescriptorProto.Type.TYPE_INT64,
options: {},
},
],
},
],
};
const NestedProto = Type.fromDescriptor(protoDescriptor);
const raw = {
record_id: '12345',
recordDetails: [
{key: 'name', value: 'jimmy'},
{key: 'title', value: 'clown'},
],
metadata: {
createdAt: Date.now(),
updatedAt: Date.now(),
},
};
const serialized = NestedProto.encode(raw).finish();
const decoded = NestedProto.decode(serialized).toJSON();
assert.deepEqual(raw, decoded);
error:
/Users/aviebrantz/develop/node/nodejs-bigquery-storage/node_modules/protobufjs/src/namespace.js:411
var found = this.root._fullyQualifiedObjects["." + flatPath];
^
TypeError: Cannot read properties of undefined (reading '.Nested_recordDetails')
at Type.lookup (/Users/aviebrantz/develop/node/nodejs-bigquery-storage/node_modules/protobufjs/src/namespace.js:411:49)
at Type.lookupTypeOrEnum (/Users/aviebrantz/develop/node/nodejs-bigquery-storage/node_modules/protobufjs/src/namespace.js:519:22)
at Field.resolve (/Users/aviebrantz/develop/node/nodejs-bigquery-storage/node_modules/protobufjs/src/field.js:304:94)
at Type.set (/Users/aviebrantz/develop/node/nodejs-bigquery-storage/node_modules/protobufjs/src/type.js:177:38)
at Type.get (/Users/aviebrantz/develop/node/nodejs-bigquery-storage/node_modules/protobufjs/src/type.js:155:45)
at Field.resolve (/Users/aviebrantz/develop/node/nodejs-bigquery-storage/node_modules/protobufjs/src/field.js:356:21)
at Type.setup (/Users/aviebrantz/develop/node/nodejs-bigquery-storage/node_modules/protobufjs/src/type.js:460:41)
at Type.encode_setup [as encode] (/Users/aviebrantz/develop/node/nodejs-bigquery-storage/node_modules/protobufjs/src/type.js:510:17)
at Object.<anonymous> (/Users/aviebrantz/develop/node/nodejs-bigquery-storage/protobuf-issue.js:88:32)
at Module._compile (node:internal/modules/cjs/loader:1159:14)
Node.js v18.12.1