Fix: Ensure unpacked data is an array before using array_key_exists() - #39
Conversation
Throws a RecvFailedException if the unpacked data is not an array, improving error handling for invalid responses.
|
Warning Rate limit exceeded@huangdijia has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 25 minutes and 3 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (1)
WalkthroughAdds a defensive cast and validation for JSON-RPC responses in Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant Caller
participant Client
participant Transport
participant JSON as JSON Decoder
Caller->>Client: request(params)
Client->>Transport: send RPC request
Transport-->>Client: raw response (string) $ret
Client->>JSON: decode($ret)
JSON-->>Client: decoded value
alt decoded is array and contains "result"
Client-->>Caller: return decoded["result"]
else decoded not an array
note right of Client #FFDDAA: New validation — cast and check
Client-->>Caller: throw RecvFailedException(msg includes raw $ret)
else non-JSONRPC error path
Client-->>Caller: existing error handling
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/Client.php(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/Client.php (6)
src/Functions.php (1)
with(111-114)src/Contract/PackerInterface.php (1)
unpack(18-18)src/Packer/JsonEofPacker.php (1)
unpack(41-44)src/Packer/GrpcPacker.php (1)
unpack(23-26)src/Packer/JsonLengthPacker.php (1)
unpack(57-66)src/Exception/RecvFailedException.php (1)
RecvFailedException(14-16)
…#39) * Fix: Ensure unpacked data is an array before using array_key_exists() * Add validation for unpacked data in Client Throws a RecvFailedException if the unpacked data is not an array, improving error handling for invalid responses. * Fix: Ensure unpacked data is treated as an array in Client * chore: Add allow-plugins configuration for composer-normalize * Fix: Ensure unpacked data is treated as an array and improve error handling in Client * Fix: Improve error message for invalid data in ServerException --------- Co-authored-by: 范冠登 <guandeng@addcn.com> Co-authored-by: Deeka Wong <8337659+huangdijia@users.noreply.github.com>
…#39) * Fix: Ensure unpacked data is an array before using array_key_exists() * Add validation for unpacked data in Client Throws a RecvFailedException if the unpacked data is not an array, improving error handling for invalid responses. * Fix: Ensure unpacked data is treated as an array in Client * chore: Add allow-plugins configuration for composer-normalize * Fix: Ensure unpacked data is treated as an array and improve error handling in Client * Fix: Improve error message for invalid data in ServerException --------- Co-authored-by: 范冠登 <guandeng@addcn.com> Co-authored-by: Deeka Wong <8337659+huangdijia@users.noreply.github.com>
…#39) * Fix: Ensure unpacked data is an array before using array_key_exists() * Add validation for unpacked data in Client Throws a RecvFailedException if the unpacked data is not an array, improving error handling for invalid responses. * Fix: Ensure unpacked data is treated as an array in Client * chore: Add allow-plugins configuration for composer-normalize * Fix: Ensure unpacked data is treated as an array and improve error handling in Client * Fix: Improve error message for invalid data in ServerException --------- Co-authored-by: 范冠登 <guandeng@addcn.com> Co-authored-by: Deeka Wong <8337659+huangdijia@users.noreply.github.com>
Summary by CodeRabbit
Bug Fixes
Chores