Skip to content

fix: handle missing features in feed settings response#1025

Merged
kylemcd merged 2 commits into
knocklabs:mainfrom
abdtriedcoding:fix/feed-settings-missing-features
Jul 8, 2026
Merged

fix: handle missing features in feed settings response#1025
kylemcd merged 2 commits into
knocklabs:mainfrom
abdtriedcoding:fix/feed-settings-missing-features

Conversation

@abdtriedcoding

Copy link
Copy Markdown
Contributor

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

@changeset-bot

changeset-bot Bot commented Jun 30, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 4c856e2

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.

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>
@kylemcd kylemcd force-pushed the fix/feed-settings-missing-features branch from 089e177 to 7a8dfbb Compare July 8, 2026 14:08
@kylemcd

kylemcd commented Jul 8, 2026

Copy link
Copy Markdown
Member

thanks @abdtriedcoding! pushed a couple edits on top:

  • rebased onto main — @knocklabs/client just swapped axios for fetch (Replace @knocklabs/client axios transport with fetch #1010), so this needed to sit on the new transport
  • instead of defaulting branding_required: false when the body is missing features, we now leave settings null. a flaky 200 (captive portal/proxy) shouldn't silently hide required branding. guard is response.statusCode === "ok" && response.body?.features now, and updated the test to match

same crash fix, just doesn't assume a branding value we never got. thanks again!

@vercel

vercel Bot commented Jul 8, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
javascript-ms-teams-connect-example Ready Ready Preview, Comment Jul 8, 2026 2:30pm
javascript-nextjs-example Ready Ready Preview, Comment Jul 8, 2026 2:30pm

Request Review

A flaky connection (captive portal, proxy) can return an HTTP 200 whose body is not the feed settings payload. Fabricating branding_required: false from such a body silently suppresses branding when it is required.

Only store settings on a genuine success whose body actually contains a features object; otherwise leave settings null (which the optional chaining in the feed components already renders safely).
@codecov

codecov Bot commented Jul 8, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.90909% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 64.49%. Comparing base (b6c9be4) to head (4c856e2).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...ts/NotificationFeedComponents/NotificationFeed.tsx 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1025      +/-   ##
==========================================
+ Coverage   64.46%   64.49%   +0.02%     
==========================================
  Files         212      212              
  Lines       10211    10217       +6     
  Branches     1389     1389              
==========================================
+ Hits         6583     6589       +6     
  Misses       3603     3603              
  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%> (ø)

@kylemcd kylemcd merged commit 70e7669 into knocklabs:main Jul 8, 2026
8 of 12 checks passed
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

3 participants