Skip to content

Conversation

@speaker-ender
Copy link
Contributor

@speaker-ender speaker-ender commented Dec 5, 2025

Ticket ENG-2171

Description Of Changes

Partial rollback of data normalization to fix data updates.

Code Changes

  • Uses non-normalized details data
  • Temporary fix for mutable map objects

Steps to Confirm

  1. Visit a monitor in the action center.
  2. Open the details drawer for a field
  3. Edit the data categories
  4. Confirm that data categories are updated in the details view and the list view
  5. Verify there are no regressions with existing functionality of the screen

Pre-Merge Checklist

  • Issue requirements met
  • All CI pipelines succeeded
  • CHANGELOG.md updated
    • Add a db-migration This indicates that a change includes a database migration label to the entry if your change includes a DB migration
    • Add a high-risk This issue suggests changes that have a high-probability of breaking existing code label to the entry if your change includes a high-risk change (i.e. potential for performance impact or unexpected regression) that should be flagged
    • Updates unreleased work already in Changelog, no new entry necessary
  • UX feedback:
    • All UX related changes have been reviewed by a designer
    • No UX review needed
  • Followup issues:
    • Followup issues created
    • No followup issues
  • Database migrations:
    • Ensure that your downrev is up to date with the latest revision on main
    • Ensure that your downgrade() migration is correct and works
      • If a downgrade migration is not possible for this change, please call this out in the PR description!
    • No migrations
  • Documentation:
    • Documentation complete, PR opened in fidesdocs
    • Documentation issue created in fidesdocs
    • If there are any new client scopes created as part of the pull request, remember to update public-facing documentation that references our scope registry
    • No documentation updates required

@vercel
Copy link

vercel bot commented Dec 5, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

2 Skipped Deployments
Project Deployment Preview Comments Updated (UTC)
fides-plus-nightly Ignored Ignored Preview Dec 5, 2025 4:51pm
fides-privacy-center Ignored Ignored Dec 5, 2025 4:51pm

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Dec 5, 2025

Greptile Overview

Greptile Summary

This PR partially rolls back the data normalization feature to fix data update issues in the Action Center fields view. The changes address a mutable Map object mutation bug by adding cloneDeep to the merge logic, but intentionally bypass the merge result when setting state as a temporary workaround.

Key changes:

  • Fixed mutation bug in mergeNodes by adding _.cloneDeep() before merge
  • Removed initialData parameter from useNodeMap hook
  • Disabled details query normalization in useNormalizedResources - details now return raw API data instead of normalized node
  • Switched from listQuery.data to listQuery.currentData (RTK Query property that only updates when the current query succeeds)

Trade-offs:

  • The partialUpdates parameter now only affects change detection, not the actual state merge - this is acknowledged in a code comment as a temporary fix
  • Test expectations were updated to reflect this changed behavior (nodes now overwrite rather than merge)

Confidence Score: 4/5

  • This PR is safe to merge as a temporary fix, with the behavior changes being intentional and documented.
  • The changes are well-tested, the mutation bug fix is correct, and the temporary workaround is clearly documented in comments. The behavior change to normalization is intentional and test expectations were updated accordingly. However, a follow-up issue should track restoring full merge functionality.
  • Pay attention to useNodeMap.ts - the partialUpdates parameter behavior has changed and may need follow-up to restore full merge functionality.

Important Files Changed

File Analysis

Filename Score Overview
clients/admin-ui/src/features/common/hooks/useNodeMap.ts 3/5 Fixes mutation bug with cloneDeep but introduces inconsistency: draft is computed but next is used for state update when partialUpdates=true. The comment explains this is intentional as a temporary fix.
clients/admin-ui/src/features/common/hooks/useNodeMap.test.ts 4/5 Test expectations updated to reflect changed behavior. Removed duplicate test. Added new tests for mergeNodes including a test verifying no data mutation.
clients/admin-ui/src/features/data-discovery-and-detection/action-center/fields/useNormalizedResources.ts 3/5 Switched from data to currentData (RTK Query), disabled details query normalization, and returns raw data instead of normalized node for details query.
clients/admin-ui/src/features/data-discovery-and-detection/action-center/fields/page.tsx 5/5 Updated destructuring to match new return type: data instead of node for details query resource.

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

4 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

_.chain(prev.get(key)).defaultTo(node).merge(node).value(),
_.chain(prev.get(key))
.defaultTo(node)
.cloneDeep() /** This is needed since we aren't using immutable Maps (yet), and would otherwise mutate referenced objects */
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maps use mutable refs.
This can cause lots of issues and is why I typically avoid them but here we are.
Cloning the referenced data before merging leaves the initial value as it should be.

_.chain(prev.get(key))
.defaultTo(node)
.cloneDeep() /** This is needed since we aren't using immutable Maps (yet), and would otherwise mutate referenced objects */
.merge(node)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Lodash merge does not do exactly what we want and would need to be replaced with a mergeWith fn in the future.
This works fine for the current implementation.

fix: normalization merging

fix: tests and expected behavior

revert: changing from data to currentData
@speaker-ender speaker-ender force-pushed the fix/normalization-merging branch from d243498 to 15164b1 Compare December 5, 2025 15:23
]);
});

it("should not mutate data references", () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This only tests that we are not mutating the refs internally.
Ideally, we should have immutable values when dealing with maps externally but this will most likely require a library.

const {
listQuery: { nodes: listNodes, ...listQueryMeta },
detailsQuery: { node: resource },
detailsQuery: { data: resource },
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Relying on the query directly since we aren't updating the node values with the details query.

.value();

const useNodeMap = <Data>(
initialData?: NodeMap<Data>,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removing initial data since it's not necessary at the moment + introduces another vector for mutability issues

@speaker-ender speaker-ender changed the title fix: normalization merging fix: normalization merging [ENG-2171] Dec 5, 2025
…ion-center/fields/useNormalizedResources.ts

Co-authored-by: Jason Gill <jason.gill@ethyca.com>
@speaker-ender speaker-ender added this pull request to the merge queue Dec 5, 2025
Merged via the queue into main with commit f7ad962 Dec 5, 2025
47 checks passed
@speaker-ender speaker-ender deleted the fix/normalization-merging branch December 5, 2025 17:15
speaker-ender added a commit that referenced this pull request Dec 5, 2025
Co-authored-by: Jason Gill <jason.gill@ethyca.com>
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