Skip to content

ENG-3603: Fix custom field updates on privacy declarations#8024

Merged
dsill-ethyca merged 2 commits intomainfrom
jpople/eng-3603/fix-custom-field-upsert
Apr 24, 2026
Merged

ENG-3603: Fix custom field updates on privacy declarations#8024
dsill-ethyca merged 2 commits intomainfrom
jpople/eng-3603/fix-custom-field-upsert

Conversation

@jpople
Copy link
Copy Markdown
Contributor

@jpople jpople commented Apr 24, 2026

Ticket ENG-3603

Description Of Changes

Fixes a bug where updating custom fields on privacy declarations would fail with either a "duplicate key value violates unique constraint" or "null value in column id violates not-null constraint" error.

Root cause: buildCustomFieldsPayload in useSystemDataUseCrud.ts was incorrectly using the custom field definition ID as the custom field record ID in the upsert payload. Since definition IDs are shared across all declarations, the second declaration's custom fields would collide with the first's on the primary key. Additionally, the declaration matching after save only checked data_use, not name, which could target the wrong declaration when multiple share the same data use.

Companion PR: Requires ethyca/fidesplus PR (linked in ENG-3603) for the backend fix that strips id from the bulk update dict to prevent SET id=NULL when the frontend omits the field.

Code Changes

  • Removed id from the upsert payload in buildCustomFieldsPayload — the backend finds existing records by (resource_id, custom_field_definition_id) and auto-generates UUIDs for new ones
  • Fixed declaration matching in patchDataUses to use both data_use and name, consistent with the backend's privacy_declaration_logical_id
  • Normalized null/empty name comparison in declarationAlreadyExists to match backend behavior (null and "" treated as equivalent)

Steps to Confirm

  1. Create a system with two privacy declarations that have different data uses
  2. Add custom field definitions for the "privacy declaration" resource type
  3. Set custom field values on the first declaration — should save without error
  4. Set custom field values on the second declaration — should save without error (previously failed with duplicate key violation)
  5. Edit a custom field value on one declaration — should only change that declaration, not the other

Pre-Merge Checklist

  • Issue requirements met
  • All CI pipelines succeeded
  • CHANGELOG.md updated
    • Add a db-migration label
    • Add a high-risk label
    • Updates unreleased work already in Changelog
  • UX feedback:
    • No UX review needed
  • Followup issues:
    • No followup issues
  • Database migrations:
    • No migrations
  • Documentation:
    • No documentation updates required

@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented Apr 24, 2026

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

2 Skipped Deployments
Project Deployment Actions Updated (UTC)
fides-plus-nightly Ignored Ignored Apr 24, 2026 3:11am
fides-privacy-center Ignored Ignored Apr 24, 2026 3:11am

Request Review

@github-actions
Copy link
Copy Markdown

Title Lines Statements Branches Functions
admin-ui Coverage: 8%
6.32% (2799/44262) 5.56% (1402/25174) 4.42% (579/13087)
fides-js Coverage: 78%
79.39% (2011/2533) 65.99% (1240/1879) 73.09% (345/472)
privacy-center Coverage: 88%
85.97% (331/385) 81.36% (179/220) 78.87% (56/71)

@jpople jpople marked this pull request as ready for review April 24, 2026 04:19
@jpople jpople requested a review from a team as a code owner April 24, 2026 04:19
@jpople jpople requested review from kruulik and removed request for a team April 24, 2026 04:19
@speaker-ender speaker-ender self-requested a review April 24, 2026 14:56
Copy link
Copy Markdown
Contributor

@kruulik kruulik left a comment

Choose a reason for hiding this comment

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

Looks good to me!

@dsill-ethyca dsill-ethyca added this pull request to the merge queue Apr 24, 2026
Merged via the queue into main with commit 8fc5e91 Apr 24, 2026
53 checks passed
@dsill-ethyca dsill-ethyca deleted the jpople/eng-3603/fix-custom-field-upsert branch April 24, 2026 17:36
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