fix: handle missing features in feed settings response#1025
Conversation
🦋 Changeset detectedLatest commit: 4c856e2 The changes in this PR will be included in the next version bump. This PR includes changesets to release 7 packages
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 |
|
@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>
089e177 to
7a8dfbb
Compare
|
thanks @abdtriedcoding! pushed a couple edits on top:
same crash fix, just doesn't assume a branding value we never got. thanks again! |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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).
7a8dfbb to
4c856e2
Compare
Codecov Report❌ Patch coverage is
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
|
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
featuresobject). The SDK then crashed with:TypeError: can't access property "branding_required", v.features is undefinedThis PR:
useFeedSettingssofeatures.branding_requiredalways defaults safely when missingfeaturesin both web and React NativeNotificationFeedcomponentsTodos
None.
Checklist
Test plan
yarn test—useFeedSettingstests pass (including new partial response case)yarn workspace @knocklabs/react-core type:checkpassesyarn workspace @knocklabs/react-core lintpassesyarn workspace @knocklabs/react lintpassesyarn workspace @knocklabs/react-native lintpasses