-
Notifications
You must be signed in to change notification settings - Fork 56
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
utf-8/encoding bug #171
Comments
I expected this to insert the same key twice because æ and ø both become 0xEFBFBD using the following code: await table.mutate([
{
key: Buffer.from('æ', 'binary'),
method: 'insert',
data: {
c: {
test: Buffer.from('æ', 'binary')
}
}
},
{
key: Buffer.from('ø', 'binary'),
method: 'insert',
data: {
c: {
test: Buffer.from('x', 'binary')
}
}
},
]); But instead I stumbled upon another problem. Running the repro code from the original post now outputs the following error even after uncommenting the mutation above.
|
Expected result is that both queries works, but the second one still fails after that one conflicting mutation. await bt.table('test2').getRows().catch(err => console.log('test2', err.message));
console.log('OK!');
await bt.table('test').getRows().catch(err => console.log('test', err.message));
|
I think that this is a client-side problem related to to the encoding issue. |
Deleting the row solved the getRows problem await table.mutate([
{
key: Buffer.from('ø', 'binary'),
method: 'delete',
},
]); |
@kolodny, should we keep this as a P0? |
Thanks @moander for this bug report. After digging into it, I found that nodejs treats
We can what's happening here manifesting in the following: console.log(`Buffer.from('æ', 'binary') is`, Buffer.from('æ', 'binary'));
console.log(`Buffer.from('æ') is`, Buffer.from('æ'));
console.log(`Buffer.from('æ', 'binary').toString() is`, Buffer.from('æ', 'binary').toString());
console.log(`Buffer.from('æ').toString() is`, Buffer.from('æ').toString());
/* outputs
Buffer.from('æ', 'binary') is <Buffer e6>
Buffer.from('æ') is <Buffer c3 a6>
Buffer.from('æ', 'binary').toString() is �
Buffer.from('æ').toString() is æ
*/ Combining this with the fact that rowKeys are auto-stringified from a buffer even with decode set to false, is causing the keys to look all weird when in fact they are the same buffer provided from node before being passed to the insert call. I'm going to open an issue to not convert row keys to strings when decode is set to false. Let me know if that addresses your concerns. Thanks! |
Thanks @kolodny. My issue is more related to problem 2 binary filters. The problems with the key was something I guessed would also be there because of the filtering problems ;) |
Addresses #171 - [x] Tests and linter pass - [x] Code coverage does not decrease (if any source code was changed)
@kolodny, are we done with this issue? If so, can you please close it? |
I'm gonna close this for now. @moander feel free to reopen if your issue isn't being addressed. |
After updating package to master branch I get this error:
My previous version was 0.14.0. Downgrading package solves the problem. |
Change that line to
const bigtable = new require('@google-cloud/bigtable')(bigtableConfig());
…On Thu, Jun 14, 2018, 3:31 AM Morten Andersen ***@***.***> wrote:
After updating package to master branch I get this error:
const bigtable = ***@***.***/bigtable')(bigtableConfig());
^
TypeError: Class constructor Bigtable cannot be invoked without 'new'
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
<#171 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABIfFKVViOXssxfzloi_DSHCO19BWAv7ks5t8hFagaJpZM4Ue_0y>
.
|
@kolodny same error using I had to do this: const Bigtable = require('@google-cloud/bigtable');
const bigtable = new Bigtable(); The others work with //const bigtable = new require('@google-cloud/bigtable')();
const datastore = new require('@google-cloud/datastore')();
const storage = new require('@google-cloud/storage')();
const pubsub = new require('@google-cloud/pubsub')();
const bigquery = new require('@google-cloud/bigquery')(); |
@kolodny filter repro returns same result from master branch
You also see that |
The problem where The following code makes await table.mutate([
{
key: Buffer.from('æ', 'binary'),
method: 'insert',
data: {
c: {
test: Buffer.from('æ', 'binary')
}
}
},
{
key: Buffer.from('ø', 'binary'),
method: 'insert',
data: {
c: {
test: Buffer.from('x', 'binary')
}
}
},
]); |
Please see my comments here #129 (review)
Problem 1:
Binary values in key will get unexpected values using binary values in buffers.
Problem 2:
Binary value filters will not return any matches
Problem 3:
TransformError from getRows after inserting unique keys 0xE6 and 0xF8
Environment details
@google-cloud/bigtable
version: 0.14.0Steps to reproduce
Output:
The text was updated successfully, but these errors were encountered: