fix: make packed any size fallible#16
Conversation
|
Warning Rate limit exceeded
To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing. ⌛ 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. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Review rate limit: 0/1 reviews remaining, refill in 3 minutes and 37 seconds.Comment |
Summary
sizeOfPackedAny()return!usize.sliceBug
sizeOfPackedAny()delegated to helpers such assizeOfPackedString()andsizeOfPackedArray(), which can fail for values that are too large to encode. The wrapper returned a plainusize, so it could not correctly propagate those errors.The helper also checked
ptr_info.size == .Slice, but Zig's pointer size tag is.slice. InstantiatingsizeOfPackedAny()for slices failed to compile on Zig 0.16.This changes
sizeOfPackedAny()to return!usize, forwards size-helper errors, and handles optional nulls explicitly as the MessagePack null size.The new tests demonstrate the compile failures first for string slices, non-u8 array slices, and optional null/value cases.
Tests
zig build test --summary allfailed before the fix with.Sliceand non-fallible return type errors./check.sh --ci