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

Null character "\u0000" in transaction type 0 data field throws error #2370

Closed
shuse2 opened this Issue Sep 3, 2018 · 0 comments

Comments

Projects
None yet
3 participants
@shuse2
Contributor

shuse2 commented Sep 3, 2018

Description

Special character (Null Character “\u0000”) cannot be converted from database type “bytea” to “text”, which causes the database to throw an error. Null character “\u0000” is a valid UTF8 character in Node.js, but Postgres is not able to convert the null character from the bytea to Text. In our case, transaction type 0 data field was saved in “bytea”, which accepts the null character. However, when we get the transaction information from the database, it is converted from “bytea” to “text” format in database layer.

Expected behaviour

It should not fail when reading from the database.

Actual behaviour

The current code converts the bytea code to utf-8 and PostgreSQL can't convert null octet to utf8, the following part of the code causes the error
https://github.com/LiskHQ/lisk/blob/1.0.0/db/sql/migrations/updates/20171207000007_recreate_full_block_list_view.sql#L67

Steps to reproduce

SELECT CONVERT_FROM("data", 'utf8') AS "tf_data" from transfer where "transactionId" = '10589655532517440995'

Which version(s) does this affect? (Environment, OS, etc...)

v1.0.0, 1.0.1

@shuse2 shuse2 added the bug label Sep 3, 2018

@shuse2 shuse2 closed this Sep 3, 2018

@shuse2 shuse2 changed the title from Null character "\u0000" in transaction type 0 data field to Null character "\u0000" in transaction type 0 data field throws error Sep 3, 2018

diego-G added a commit that referenced this issue Oct 11, 2018

diego-G added a commit that referenced this issue Oct 12, 2018

diego-G added a commit that referenced this issue Oct 15, 2018

diego-G added a commit that referenced this issue Oct 15, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment