fix: A null Date field is returned as epoch (1970) instead of null#10547
fix: A null Date field is returned as epoch (1970) instead of null#10547dblythy wants to merge 1 commit into
Conversation
|
🚀 Thanks for opening this pull request! We appreciate your effort in improving the project. Please let us know once your pull request is ready for review. Tip
Note Please respond to review comments from AI agents just like you would to comments from a human reviewer. Let the reviewer resolve their own comments, unless they have reviewed and accepted your commit, or agreed with your explanation for why the feedback was incorrect. Caution Pull requests must be written using an AI agent with human supervision. Pull requests written entirely by a human will likely be rejected, because of lower code quality, higher review effort and the higher risk of introducing bugs. Please note that AI review comments on this pull request alone do not satisfy this requirement. Our CI and AI review are safeguards, not development tools. If many issues are flagged, rethink your development approach. Invest more effort in planning and design rather than using review cycles to fix low-quality code. |
📝 WalkthroughWalkthroughModified ChangesNull Date Field Fix
Estimated code review effort: 1 (Trivial) | ~5 minutes Related issues: Suggested labels: bug, mongodb Suggested reviewers: dblythy, mtrezza 🐛 A date once null, now stays null and true, 🚥 Pre-merge checks | ✅ 5 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
spec/MongoTransform.spec.js (1)
432-445: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winMissing regression coverage for the non-null Date case.
Both new tests only exercise
nullinput. Adding a companion assertion for a non-nullexpiresAt/lastUsedvalue would guard against the format regression flagged inMongoTransform.js(e.g., assertingoutput.expiresAt.__type === 'Date'and the expected.isovalue), since the null-check refactor also touched the non-null branch.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@spec/MongoTransform.spec.js` around lines 432 - 445, Add regression coverage in the existing MongoTransform spec for the non-null Date path alongside the new null cases. In the same test area that calls transform.mongoObjectToParseObject for expiresAt and lastUsed, include assertions for a real Date value so the non-null branch in MongoTransform.js is verified too, checking the returned Parse Date shape and expected ISO string through output.expiresAt and output.lastUsed.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@spec/MongoTransform.spec.js`:
- Around line 432-445: Add regression coverage in the existing MongoTransform
spec for the non-null Date path alongside the new null cases. In the same test
area that calls transform.mongoObjectToParseObject for expiresAt and lastUsed,
include assertions for a real Date value so the non-null branch in
MongoTransform.js is verified too, checking the returned Parse Date shape and
expected ISO string through output.expiresAt and output.lastUsed.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: cf25b688-3900-4089-8171-6d0a4bb08f3e
📒 Files selected for processing (2)
spec/MongoTransform.spec.jssrc/Adapters/Storage/Mongo/MongoTransform.js
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## alpha #10547 +/- ##
=======================================
Coverage 92.66% 92.66%
=======================================
Files 193 193
Lines 16981 16981
Branches 248 248
=======================================
Hits 15736 15736
Misses 1224 1224
Partials 21 21 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
@coderabbitai does a fix need to be applied elsewhere in the code to patch Date on standard objects or fields ? It seems the fix is scoped on a specific field |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -e
fd MongoTransform.js
echo "---outline---"
ast-grep outline src/Adapters/Storage/Mongo/MongoTransform.js --items all | head -100
echo "---mongoObjectToParseObject---"
rg -n "mongoObjectToParseObject" -A 100 src/Adapters/Storage/Mongo/MongoTransform.js | head -200Length of output: 6513 🏁 Script executed: #!/bin/bash
sed -n '1213,1280' src/Adapters/Storage/Mongo/MongoTransform.jsLength of output: 430 🏁 Script executed: #!/bin/bash
awk 'NR>=1213 && NR<=1290' src/Adapters/Storage/Mongo/MongoTransform.jsLength of output: 2987 🏁 Script executed: #!/bin/bash
awk 'NR>=1034 && NR<=1105' src/Adapters/Storage/Mongo/MongoTransform.js
echo "---valueAsDate---"
awk 'NR>=218 && NR<=230' src/Adapters/Storage/Mongo/MongoTransform.jsLength of output: 2634
Custom/user-defined case 'object':
if (mongoObject === null) {
return null;
}So a However, the same bug pattern still exists for two other hardcoded fields in case 'updatedAt':
case '_updated_at':
restObject['updatedAt'] = Parse._encode(new Date(mongoObject[key])).iso;
break;
case 'createdAt':
case '_created_at':
restObject['createdAt'] = Parse._encode(new Date(mongoObject[key])).iso;
break;These call So to summarize:
Would you like me to open a follow-up issue for applying the same null-guard to |
|
@dblythy maybe be createdAt and updatedAt should be also patched ? |
Closes #7576
Summary by CodeRabbit
expiresAtandlastUsedvalues staynullinstead of being turned into a date value.nullhandling onexpiresAtandlastUsedto prevent regressions.