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

firestore: marshal values as []byte, not string #4160

Merged
merged 2 commits into from
Aug 11, 2020

Conversation

awly
Copy link
Contributor

@awly awly commented Aug 4, 2020

Firestore marshaler requires all string data to be valid UTF-8. Our
values are sometimes binary (like QR codes for OTP signup), which would
fail to marhal.

On reads, try using both new and old formats to support existing data.

Added tests for this fallback and for writing binary data into all
backends.

Tested with firestore, including upgrade from an existing teleport cluster.

Fixes #4145

@webvictim
Copy link
Contributor

Looks like the linter is failing.

Firestore marshaler requires all string data to be valid UTF-8. Our
values are sometimes binary (like QR codes for OTP signup), which would
fail to marhal.

On reads, try using both new and old formats to support existing data.

Added tests for this fallback and for writing binary data into all
backends.
@awly awly force-pushed the andrew/firestore-binary-data branch from 98433c7 to 4105887 Compare August 10, 2020 15:57
@awly
Copy link
Contributor Author

awly commented Aug 10, 2020

Fixed linter failures

@@ -110,13 +110,63 @@ type FirestoreBackend struct {
}

type record struct {
Key string `firestore:"key,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should Key be changed to []byte as well while we're here? I don't think we enforce UTF-8 on keys either.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. In practice it seems to always be UTF-8, but it's not enforced anywhere.
Changed and added test coverage for other backends.

Same as values, `backend.Item` passes keys as `[]byte` and has no
guarantees about the encoding. GetRange queries need extra care because
of this type mismatch too: `where` clauses are type-sensitive.
@awly awly force-pushed the andrew/firestore-binary-data branch from bfe8eb9 to 6a212f1 Compare August 11, 2020 18:09
@awly awly merged commit b90452e into master Aug 11, 2020
@awly awly deleted the andrew/firestore-binary-data branch August 11, 2020 18:40
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

Successfully merging this pull request may close these issues.

Firestore: Local User Setup Error
3 participants