fix(hooks): add null check to data before further deserialization#1822
fix(hooks): add null check to data before further deserialization#1822
Conversation
📝 WalkthroughWalkthroughThe changes in this pull request involve modifications to the Changes
Sequence Diagram(s)sequenceDiagram
participant Caller
participant SWR
participant TanstackQuery
Caller->>SWR: Call unmarshal
SWR->>SWR: Check if parsed is an object
alt parsed is an object
SWR->>SWR: Access parsed.data and parsed.meta?.serialization
else parsed is not an object
SWR->>Caller: Return error or handle case
end
Caller->>TanstackQuery: Call unmarshal
TanstackQuery->>TanstackQuery: Check if parsed is an object
alt parsed is an object
TanstackQuery->>TanstackQuery: Access parsed.data and parsed.meta?.serialization
else parsed is not an object
TanstackQuery->>Caller: Return error or handle case
end
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (2)
packages/plugins/swr/src/runtime/index.ts(1 hunks)packages/plugins/tanstack-query/src/runtime/common.ts(1 hunks)
🔇 Additional comments (1)
packages/plugins/swr/src/runtime/index.ts (1)
Line range hint 423-428: LGTM! Good improvement in type safety.
The change enhances the robustness of data deserialization by adding proper type checking before accessing object properties. This helps prevent potential runtime errors when handling API responses.
No description provided.