protobuf-php/protobuf

Null character when serializeToJsonString is called on message

zajca opened this issue · 2 comments

zajca commented

I found weird behavior, when I serialize message to json at the end there is null character \u0000.
I can't figure out why this is happening, in the end I'm sending this to temporal and deserializing on worker where it fails with Cannot decode json string

I have reproduce this here:
https://github.com/keboola/php-storage-driver-teradata/blob/746eb8f0b7ea7d1facc4041cf5d671999a5a581c/test.php
this is only object where encountered this
https://github.com/keboola/php-storage-driver-teradata/blob/zajca-kbc-2874/proto/table.proto#L199

git clone https://github.com/keboola/php-storage-driver-teradata.git
git checkout -b zajca-kbc-2874
composer install
php test.php

This is output when I run this script (note the end):

'{"credentials":{"@type":"type.googleapis.com/keboola.storageDriver.credentials.GenericBackendCredentials","host":"xxx","principal":"xxx","secret":"xxx","meta":{"@type":"type.googleapis.com/keboola.storageDriver.credentials.GenericBackendCredentials.TeradataCredentialsMeta","database":"xxx"}},"command":{"@type":"type.googleapis.com/keboola.storageDriver.command.table.TableImportFromFileCommand","formatTypeOptions":{"@type":"type.googleapis.com/keboola.storageDriver.command.table.TableImportFromFileCommand.CsvTypeOptions","columnsNames":["id","name","city","sex"],"delimiter":",","enclosure":"\\"","compression":"GZIP"},"filePath":{"root":"xxx","path":"xxx","fileName":"xxx"},"fileCredentials":{"@type":"type.googleapis.com/keboola.storageDriver.command.table.ImportExportShared.S3Credentials","key":"xxx","secret":"xxx","region":"eu-central-1"},"destination":{"path":["xxx"],"tableName":"xxx"},"importOptions":{"timestampColumn":"_timestamp","numberOfIgnoredLines":1,"dedupType":"INSERT_DUPLICATES"},"meta":{"@type":"type.googleapis.com/keboola.storageDriver.command.table.TableImportFromFileCommand.TeradataTableImportMeta"}}}' . "\0" . ''

This is what I see in debuger in my app:
image

Looks like you are using google/protobuf not protobuf-php/protobuf

zajca commented

Ah sorry, I missed correct repo.