Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion clients/fides-js/__tests__/lib/consent-utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ describe("shouldResurfaceBanner", () => {
},
savedConsent: mockSavedConsent,
options: {},
expected: false,
expected: true,
},
{
label: "returns false for TCF when there are no vendors",
Expand Down
8 changes: 8 additions & 0 deletions clients/fides-js/src/lib/consent-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,14 @@ export const shouldResurfaceBanner = (
if (!!options && isConsentOverride(options)) {
return false;
}

if (
cookie.fides_meta.consentMethod === ConsentMethod.DISMISS ||
cookie.fides_meta.consentMethod === ConsentMethod.REJECT
) {
return true;
}
Comment on lines +287 to +292
Copy link
Contributor

Choose a reason for hiding this comment

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

Possible crash on missing meta

cookie.fides_meta.consentMethod is accessed without guarding cookie.fides_meta. If a persisted/legacy cookie exists without fides_meta (or it’s been partially cleared), shouldResurfaceBanner() will throw for TCF experiences, breaking banner rendering. Consider optional-chaining (e.g. cookie.fides_meta?.consentMethod) or defaulting fides_meta when deserializing cookies so this path can’t throw.


if (experience.meta?.version_hash) {
return experience.meta.version_hash !== cookie.tcf_version_hash;
}
Expand Down
Loading