Skip to content

ENG-3440: Fix TypeError when closing Data Catalog drawer#7925

Merged
gilluminate merged 2 commits intomainfrom
gill/ENG-3440/fix-data-catalog-drawer-error
Apr 15, 2026
Merged

ENG-3440: Fix TypeError when closing Data Catalog drawer#7925
gilluminate merged 2 commits intomainfrom
gill/ENG-3440/fix-data-catalog-drawer-error

Conversation

@gilluminate
Copy link
Copy Markdown
Contributor

@gilluminate gilluminate commented Apr 14, 2026

Ticket ENG-3440

Description Of Changes

Fixes a TypeError: Cannot read properties of undefined (reading 'privacy_declarations') that occurs when closing the Data Catalog drawer. The crash happened because system.privacy_declarations was accessed directly without a null check in the onClick handler, while the dataUses derivation already used optional chaining.

The fix extracts privacy_declarations into a safe declarations variable with a ?? [] fallback, then uses that reference consistently for both the data use list and the click handler.

Code Changes

  • Extract system.privacy_declarations ?? [] into a declarations constant in EditDataUseCell.tsx
  • Replace direct system.privacy_declarations[idx] access with safe declarations[idx] in the Tag onClick handler

Steps to Confirm

  1. Enable the Data Catalog Beta flag
  2. Navigate to the Data Catalog systems view
  3. Click a system's vertical 3-dot menu and select "View details" to open the drawer
  4. Close the drawer - confirm no TypeError is thrown
  5. Open a system that has privacy declarations and verify data uses still display and are editable

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
Copy Markdown
Contributor

vercel bot commented Apr 14, 2026

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

Project Deployment Actions Updated (UTC)
fides-plus-nightly Ready Ready Preview, Comment Apr 15, 2026 5:00pm
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
fides-privacy-center Ignored Ignored Apr 15, 2026 5:00pm

Request Review

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 14, 2026

Title Lines Statements Branches Functions
admin-ui Coverage: 8%
6.1% (2663/43631) 5.22% (1293/24738) 4.19% (542/12913)
fides-js Coverage: 78%
78.98% (1962/2484) 65.55% (1214/1852) 72.57% (336/463)
privacy-center Coverage: 88%
85.97% (331/385) 81.36% (179/220) 78.87% (56/71)

@gilluminate gilluminate marked this pull request as ready for review April 14, 2026 22:06
@gilluminate gilluminate requested a review from a team as a code owner April 14, 2026 22:06
@gilluminate gilluminate requested review from lucanovera and removed request for a team April 14, 2026 22:06
Copy link
Copy Markdown

@claude claude bot left a comment

Choose a reason for hiding this comment

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

Code Review: Fix TypeError in Data Catalog Drawer

This is a small, focused bug fix — no concerns. Summary below.

What the fix does

The root cause was an inconsistency in how privacy_declarations was accessed within the same component:

  • dataUses was derived with system.privacy_declarations?.map(...) ?? [] (null-safe)
  • The onClick handler referenced system.privacy_declarations[idx] directly (not null-safe)

If privacy_declarations were undefined at render time the dataUses map would produce no tags, but if the value transitioned to undefined after an initial render (e.g. after a delete mutation settled), the click handler could be called while system.privacy_declarations was momentarily undefined, throwing the TypeError described in the changelog.

Fix quality

The fix is minimal and correct:

  1. Declares const declarations = system.privacy_declarations ?? []; once — always an array.
  2. Derives dataUses from declarations (no more optional chaining needed).
  3. Replaces system.privacy_declarations[idx] in the onClick handler with declarations[idx].

This removes the inconsistency, guarantees both usages share the same null-coalesced value, and is consistent with the TypeScript type (PrivacyDeclarationResponse[]).

Changelog

Entry is present and correctly formatted.

Verdict

✅ LGTM — no blocking issues.


🔬 Codegraph: unavailable


💡 Write /code-review in a comment to re-run this review.

Copy link
Copy Markdown
Contributor

@lucanovera lucanovera left a comment

Choose a reason for hiding this comment

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

Nice catch on this bug. Unfortunately, it looks like it's still failing when I close the drawer.

Image Image

Copy link
Copy Markdown
Contributor

@lucanovera lucanovera left a comment

Choose a reason for hiding this comment

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

Confirmed the bug is fixed now. Approved!

gilluminate and others added 2 commits April 15, 2026 10:53
…is undefined

Extract privacy_declarations into a safe `declarations` variable with
a fallback to an empty array, preventing the crash that occurs when
closing the Data Catalog drawer for systems without declarations.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@gilluminate gilluminate force-pushed the gill/ENG-3440/fix-data-catalog-drawer-error branch from 995092a to c17c5d5 Compare April 15, 2026 16:53
@gilluminate gilluminate added this pull request to the merge queue Apr 15, 2026
Merged via the queue into main with commit 670ced1 Apr 15, 2026
52 checks passed
@gilluminate gilluminate deleted the gill/ENG-3440/fix-data-catalog-drawer-error branch April 15, 2026 17:23
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.

2 participants