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 Bytes serializing not working on admin SDK[Firestore] #2476

Open
Vloz opened this issue Feb 26, 2024 · 1 comment
Open

Firestore Bytes serializing not working on admin SDK[Firestore] #2476

Vloz opened this issue Feb 26, 2024 · 1 comment

Comments

@Vloz
Copy link

Vloz commented Feb 26, 2024

  • Operating System version:w10
  • Firebase SDK version: 13.1
  • Firebase Product: Firestore
  • Node.js version: 20.11
  • NPM version: 10.3

When trying to store uint8array as Firestore.Bytes from admin-sdk throw a serializing error:

Error: Value for argument "data" is not a valid Firestore document. Couldn't serialize object of type "Bytes" (found in field "binaryData"). Firestore doesn't support JavaScript objects with custom prototypes (i.e. objects that were created via the "new" operator).

Uint8array seems to be the way to go, but then mismatch Web SDK (web sdk return bytes array as Firestore.Bytes objects).

Steps to reproduce:

import { Bytes } from "firebase/firestore";

const bin = new Uint8Array([0x48, 0x65, 0x6C, 0x6C, 0x6F]);

const fsBytes = Bytes.fromUint8Array(bin);

db.collection('your_collection').doc('your_document').set({
  binaryData: fsBytes
});
@google-oss-bot
Copy link

I found a few problems with this issue:

  • I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.
  • This issue does not seem to follow the issue template. Make sure you provide all the required information.

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

No branches or pull requests

3 participants