fix(displayId): TAMOC-401: Hotfix 2.45: Corrupted snapshot records changelog value created in resolveDuplicatedPatientIds hook#9261
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses a critical data corruption issue that occurred during the patient display ID deduplication process. The problem stemmed from Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request provides a hotfix for a data corruption issue where changelogRecords were being improperly handled during a database update. The fix correctly removes this property before the update query. My review includes a suggestion to refactor the implementation to be more declarative and avoid object mutation, which can improve code clarity and maintainability.
| .map((c) => { | ||
| const updated = { | ||
| ...c, | ||
| data: { ...c.data, displayId: `${c.data.displayId}_duplicate_2` }, | ||
| }; | ||
| delete (updated as any).changelogRecords; | ||
| return updated; | ||
| }); |
There was a problem hiding this comment.
While the current implementation is correct, you can achieve the same result more declaratively by using object destructuring to omit the changelogRecords property. This avoids mutating the updated object with delete and is generally considered a cleaner, more functional approach.
.map((c) => {
const { changelogRecords, ...rest } = c as any;
return {
...rest,
data: { ...c.data, displayId: `${c.data.displayId}_duplicate_2` },
};
});|
bugbot run |
Changes
Root cause: resolveDuplicatedPatientDisplayIds spreads the full snapshot record (including changelogRecords) into its update objects. The pg driver's parsed json value for
changelog_recordsdoesn't survive the round-trip through write-back and re-read as a proper JS Array, soextractChangelogFromSnapshotRecordsblows up trying to spread it.resolveDuplicatedPatientDisplayIds.ts— delete changelogRecords from update objects so it's excluded from the UPDATE query and the DB column keeps its original value.resolveDuplicatedPatientDisplayIds was the only hook that spread ...c from an existing snapshot record into an update, carrying changelogRecords along for the ride. No other hook has this problem.
Deploys
Tests
Review Hero
Remember to...