Skip to content

fix: coerce integerValue fields to JS number when reading documents#48

Merged
besart-finsweet merged 4 commits into
masterfrom
fix/integer-value-coercion
Apr 21, 2026
Merged

fix: coerce integerValue fields to JS number when reading documents#48
besart-finsweet merged 4 commits into
masterfrom
fix/integer-value-coercion

Conversation

@besart-finsweet
Copy link
Copy Markdown
Contributor

Firestore's REST API serializes integerValue as a JSON string to preserve int64 precision. Previously, fireworkers passed the raw value through, so consumers received "1730404244" (string) instead of 1730404244 (number) — diverging from the Firebase Admin SDK and breaking drop-in replacement for data written by other clients (Admin SDK, console, other languages). Fireworkers itself writes all numbers as doubleValue, which is why the bug hid on internal round-trips.

Breaking change note
This changes the runtime type of integerValue fields for anyone who was working around the bug. Released as a minor bump.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes Firestore document decoding so REST integerValue fields (serialized as JSON strings) are returned to consumers as JS number, aligning behavior with the Firebase Admin SDK and improving drop-in compatibility.

Changes:

  • Coerce integerValue primitive fields to number during document field extraction.
  • Add unit + emulator-backed tests to validate integerValue coercion (including nested arrays/maps).
  • Add a changeset documenting the behavior change and precision implications.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/fields.ts Updates primitive extraction to convert integerValue from string → number.
src/fields.test.ts Adds coverage for integer coercion (direct, nested, and via get against emulator).
.changeset/integer-value-coercion.md Documents the minor release + breaking behavior and precision caveat.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/fields.test.ts
Comment thread src/fields.test.ts
alexiglesias93
alexiglesias93 previously approved these changes Apr 21, 2026
Copy link
Copy Markdown
Member

@alexiglesias93 alexiglesias93 left a comment

Choose a reason for hiding this comment

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

great job

@besart-finsweet besart-finsweet merged commit 6cc5762 into master Apr 21, 2026
3 checks passed
@besart-finsweet besart-finsweet deleted the fix/integer-value-coercion branch April 21, 2026 15:48
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.

3 participants