Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to find an appropriate decode scheme #1049

Open
ashubham opened this issue May 23, 2018 · 4 comments
Open

Unable to find an appropriate decode scheme #1049

ashubham opened this issue May 23, 2018 · 4 comments

Comments

@ashubham
Copy link

protobuf.js version: 6.8.3

I updated from protobuf 4.x to 6.8.3. I made changes according to the updated API.
But, there is one error I am not able to get pass by, is to how to properly decode this type of serialized
buffer.

'\n�\u0005\n\u001c\b\u0002\u001a\u0018\b\u0001\u0012\u0014\n\u00010\u0012\u000244\u001a\u000222"\u0001**\u0001*2\u0001*\u0012$99c10c1e-2682-4033-b45a-41f6e6bb3a9e":Total count event by userGUID, event - Score 10 - Mixpanel2+author:86188142-0812-4507-8b1a-d5b5cd169b662-chart.id:a7e6eb6d-5780-40b7-b6e9-7d8cb3f07ee88����\u0005@����\u0005J$86188142-0812-4507-8b1a-d5b5cd169b66R$86188142-0812-4507-8b1a-d5b5cd169b66Z\u0002\b\u0001b\u0010\n\u0006\b\u0000\u0012\u0002\b\u0002\u0012\u0006\b\u0000\u0012\u0002\b\u0001j\u0010\n\u0006\b\u0000\u0012\u0002\b\u0002\u0012\u0006\b\u0000\u0012\u0002\b\u0001p\u0002�\u0001�\u0002\n\u001chttp://10.77.20.219:3000/run\u0012.\n\u0006author\u0012$86188142-0812-4507-8b1a-d5b5cd169b66\u0012\u0016\n\tslackUser\u0012\tU054G5J7E\u0012(\n\trecievers\u0012\u001b<@U054G5J7E|ashish.shubham>\u0012*\n\u0002id\u0012$a7e6eb6d-5780-40b7-b6e9-7d8cb3f07ee8\u00123\n\u000bpinboard.id\u0012$34a1630f-e7d3-4726-8d40-f43b84ec200b\u0012B\n\u0004name\u0012:Total count event by userGUID, event - Score 10 - Mixpanel\u0012\u0011\n\rappliedTokens\u0012\u0000�\u0001�8�\u0001<�\u0001\u0002\b\u0002\n�\u0004\n\u001c\b\u0002\u001a\u0018\b\u0001\u0012\u0014\n\u00010\u0012\u000234\u001a\u000212"\u0001**\u0001*2\u0001*\u0012$d2e53166-54f5-45da-91f0-c49b36f8d53e"\u0018Open Tickets by Priority2+author:86188142-0812-4507-8b1a-d5b5cd169b662-chart.id:da59bb8c-c193-4ca3-84de-b1c8873894498�ۣ�\u0005@����\u0005J$86188142-0812-4507-8b1a-d5b5cd169b66R$86188142-0812-4507-8b1a-d5b5cd169b66Z\u0002\b\u0001b\u0010\n\u0006\b\u0000\u0012\u0002\b\u0002\u0012\u0006\b\u0000\u0012\u0002\b\u0001j\u0010\n\u0006\b\u0000\u0012\u0002\b\u0002\u0012\u0006\b\u0000\u0012\u0002\b\u0001p\u0002�\u0001�\u0002\n\u001dhttp://192.168.2.248:3000/run\u0012.\n\u0006author\u0012$86188142-0812-4507-8b1a-d5b5cd169b66\u0012\u0016\n\tslackUser\u0012\tU054G5J7E\u0012 \n\trecievers\u0012\u0013<@U054G5J7E|ashish>\u0012*\n\u0002id\u0012$da59bb8c-c193-4ca3-84de-b1c887389449\u00123\n\u000bpinboard.id\u0012$864b39bd-d9f0-42bb-b8f7-9d6474857731\u0012 \n\u0004name\u0012\u0018Open Tickets by Priority\u0012\u0011\n\rappliedTokens\u0012\u0000�\u0001�8�\u0001<�\u0001\u0002\b\u0002\n�\u0004\n\u001c\b\u0002\u001a\u0018\b\u0001\u0012\u0014\n\u00010\u0012\u000224\u001a\u000219"\u0001**\u0001*2\u0001*\u0012$390d3737-5eec-4903-8843-b500e37ca0da"\rNPS Responses2+author:86188142-0812-4507-8b1a-d5b5cd169b662-chart.id:f31b099d-63ca-4fe6-bc89-191da31b00ba8����\u0005@����\u0005J$86188142-0812-4507-8b1a-d5b5cd169b66R$86188142-0812-4507-8b1a-d5b5cd169b66Z\u0002\b\u0001b\u0010\n\u0006\b\u0000\u0012\u0002\b\u0002\u0012\u0006\b\u0000\u0012\u0002\b\u0001j\u0010\n\u0006\b\u0000\u0012\u0002\b\u0002\u0012\u0006\b\u0000\u0012\u0002\b\u0001p\u0002�\u0001�\u0002\n\u001dhttp://192.168.2.248:3000/run\u0012.\n\u0006author\u0012$86188142-0812-4507-8b1a-d5b5cd169b66\u0012\u0016\n\tslackUser\u0012\tU054G5J7E\u0012 \n\trecievers\u0012\u0013<@U054G5J7E|ashish>\u0012*\n\u0002id\u0012$f31b099d-63ca-4fe6-bc89-191da31b00ba\u00123\n\u000bpinboard.id\u0012$97e3ebf6-1f6a-4ecb-aba8-ec4f2742eac3\u0012\u0015\n\u0004name\u0012\rNPS Responses\u0012\u0011\n\rappliedTokens\u0012\u0000�\u0001�8�\u0001<�\u0001\u0002\b\u0002\n�\u0004\n\u001c\b\u0002\u001a\u0018\b\u0001\u0012\u0014\n\u00010\u0012\u000229\u001a\u000223"\u0001**\u0001*2\u0001*\u0012$65d47389-7257-4a21-88bf-2a9e1c2cc81e"\u001dOpen Ticket Count by Priority2+author:86188142-0812-4507-8b1a-d5b5cd169b662-chart.id:f4f7bdf1-dfd8-46c9-8cd9-9d8de3bf0f1f8����\u0005@����\u0005J$86188142-0812-4507-8b1a-d5b5cd169b66R$86188142-0812-4507-8b1a-d5b5cd169b66Z\u0002\b\u0001b\u0010\n\u0006\b\u0000\u0012\u0002\b\u0002\u0012\u0006\b\u0000\u0012\u0002\b\u0001j\u0010\n\u0006\b\u0000\u0012\u0002\b\u0002\u0012\u0006\b\u0000\u0012\u0002\b\u0001p\u0002�\u0001�\u0002\n\u001dhttp://192.168.2.248:3000/run\u0012.\n\u0006author\u0012$86188142-0812-4507-8b1a-d5b5cd169b66\u0012\u0016\n\tslackUser\u0012\tU054G5J7E\u0012 \n\trecievers\u0012\u0013<@U054G5J7E|ashish>\u0012*\n\u0002id\u0012$f4f7bdf1-dfd8-46c9-8cd9-9d8de3bf0f1f\u00123\n\u000bpinboard.id\u0012$010d7a01-ec05-4af9-8a70-ec68f08c6b39\u0012%\n\u0004name\u0012\u001dOpen Ticket Count by Priority\u0012\u0011\n\rappliedTokens\u0012\u0000�\u0001�8�\u0001<�\u0001\u0002\b\u0002'

I have tried various combinations of Uint8Array.from, atob etc. But to no success, I always get an error of the form
Error: invalid wire type 6 at offset 3.

Any help would be appreciated.

@dcodeIO
Copy link
Member

dcodeIO commented May 23, 2018

Errors like these usually happen when the binary data becomes corrupted through a string conversion, like forcing it into UTF8 encoding. There is this wiki entry that might help. If a conversion to a string cannot be avoided, there's this base64 utility (available as protobuf.util.base64) that can convert the original binary data to a safe base64 encoded string first, and decode it back.

@Ishanisarkar
Copy link

Is it possible to use base64 utility with typescript definitions when generating static code with pbjs and pbts.
something like:
var encodedmessage = AwesomeMessage.base64.encode(message);
Are there any examples to refer?

@dcodeIO
Copy link
Member

dcodeIO commented Jun 4, 2018

There is no direct base64 implementation on top of the messages, but there is this utility exposed as protobuf.util.base64 to work with the underlying data, and possibly build a custom helper function from.

@Ishanisarkar
Copy link

okay.
Thank You :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants