Skip to content

fix: handle missing features in feed settings response#1025

Open
abdtriedcoding wants to merge 1 commit into
knocklabs:mainfrom
abdtriedcoding:fix/feed-settings-missing-features
Open

fix: handle missing features in feed settings response#1025
abdtriedcoding wants to merge 1 commit into
knocklabs:mainfrom
abdtriedcoding:fix/feed-settings-missing-features

Conversation

@abdtriedcoding

Copy link
Copy Markdown

Description

Fixes #1018

Users on flaky networks can receive a successful (200) response from the feed settings endpoint with a partial or empty body (e.g. missing the features object). The SDK then crashed with:

TypeError: can't access property "branding_required", v.features is undefined

This PR:

  • Normalizes feed settings in useFeedSettings so features.branding_required always defaults safely when missing
  • Adds optional chaining on features in both web and React Native NotificationFeed components
  • Adds a unit test for the partial-settings response case

Todos

None.

Checklist

  • Tests have been added for new features or major refactors to existing features.

Test plan

  • yarn testuseFeedSettings tests pass (including new partial response case)
  • yarn workspace @knocklabs/react-core type:check passes
  • yarn workspace @knocklabs/react-core lint passes
  • yarn workspace @knocklabs/react lint passes
  • yarn workspace @knocklabs/react-native lint passes

Normalize feed settings when the API returns a partial body (e.g. on flaky networks) and guard branding_required access in NotificationFeed components.

Fixes knocklabs#1018

Co-authored-by: Cursor <cursoragent@cursor.com>
@changeset-bot

changeset-bot Bot commented Jun 30, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 089e177

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 7 packages
Name Type
@knocklabs/react-core Patch
@knocklabs/react Patch
@knocklabs/react-native Patch
ms-teams-connect-example Patch
nextjs-app-dir-example Patch
slack-connect-example Patch
slack-kit-example Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel

vercel Bot commented Jun 30, 2026

Copy link
Copy Markdown

@abdtriedcoding is attempting to deploy a commit to the Knock Team on Vercel.

A member of the Team first needs to authorize it.

@codecov

codecov Bot commented Jul 7, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 63.97%. Comparing base (3dd0aa8) to head (089e177).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...ts/NotificationFeedComponents/NotificationFeed.tsx 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1025      +/-   ##
==========================================
+ Coverage   63.95%   63.97%   +0.02%     
==========================================
  Files         212      212              
  Lines       10028    10034       +6     
  Branches     1321     1322       +1     
==========================================
+ Hits         6413     6419       +6     
  Misses       3590     3590              
  Partials       25       25              
Files with missing lines Coverage Δ
...act-core/src/modules/feed/hooks/useFeedSettings.ts 100.00% <100.00%> (ø)
...d/components/NotificationFeed/NotificationFeed.tsx 75.82% <100.00%> (ø)
...ts/NotificationFeedComponents/NotificationFeed.tsx 0.00% <0.00%> (ø)

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.

Users with bad internet: can't access property "branding_required", f.features is undefined

2 participants