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

fix(NODE-5056): EJSON.parse date handling when useBigInt64=true #562

Merged
merged 7 commits into from
Feb 16, 2023

Conversation

W-A-James
Copy link
Contributor

@W-A-James W-A-James commented Feb 13, 2023

Description

EJSON.parse fails to correctly deserialize cEJSON strings which contain date fields.

What is changing?

  • EJSON.parse now correctly deserializes cEJSON dates
  • Added new BSONError subclass, BSONRuntimeError to cover internal failures
Is there new documentation needed for these changes?

No

Double check the following

  • Ran npm run lint script
  • Self-review completed using the steps outlined here
  • PR title follows the correct format: type(NODE-xxxx)[!]: description
    • Example: feat(NODE-1234)!: rewriting everything in coffeescript
  • Changes are covered by tests
  • New TODOs have a related JIRA ticket

Copy link
Contributor

@nbbeeken nbbeeken left a comment

Choose a reason for hiding this comment

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

sorry jumping on this early just noticed some things

src/extended_json.ts Outdated Show resolved Hide resolved
src/extended_json.ts Outdated Show resolved Hide resolved
src/error.ts Show resolved Hide resolved
src/error.ts Outdated Show resolved Hide resolved
@W-A-James
Copy link
Contributor Author

Should we change the tsdoc comment for the BSONError class? At the moment it reads:

BSONError objects are throw when runtime errors occur.

Having a subclass by the name of BSONRuntimeError seems confusing if that's what we have for the description of its parent class even if we specify that BSONRuntimeError specifically occurs when we have invalid internal state.

@W-A-James W-A-James changed the title NODE(5056): Fix EJSON.parse bug fix(NODE-5046): Fix EJSON.parse date handling when useBigInt64=true Feb 15, 2023
@W-A-James W-A-James changed the title fix(NODE-5046): Fix EJSON.parse date handling when useBigInt64=true fix(NODE-5056): Fix EJSON.parse date handling when useBigInt64=true Feb 15, 2023
@W-A-James W-A-James marked this pull request as ready for review February 15, 2023 20:24
@nbbeeken
Copy link
Contributor

Sounds like a good improvement although there's still plenty of usage of it, someday we'll have descriptive errors as needed. We can make it more generic and omit the "runtime" bit. "thrown when BSON encounters an error" and then maybe an additional note about how it is the parent of all other errors we intentionally throw.

@nbbeeken nbbeeken added the Primary Review In Review with primary reviewer, not yet ready for team's eyes label Feb 15, 2023
src/error.ts Outdated Show resolved Hide resolved
@nbbeeken nbbeeken added Team Review Needs review from team and removed Primary Review In Review with primary reviewer, not yet ready for team's eyes labels Feb 15, 2023
@nbbeeken nbbeeken changed the title fix(NODE-5056): Fix EJSON.parse date handling when useBigInt64=true fix(NODE-5056): EJSON.parse date handling when useBigInt64=true Feb 16, 2023
@nbbeeken nbbeeken merged commit d5088af into main Feb 16, 2023
@nbbeeken nbbeeken deleted the NODE-5056/EJSON.parse_fails_to_parse_cEJSON_Dates branch February 16, 2023 14:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Team Review Needs review from team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants