Skip to content

fix: make packed any size fallible#16

Merged
lalinsky merged 1 commit intolalinsky:mainfrom
banteg:fix/packed-any-size
Apr 30, 2026
Merged

fix: make packed any size fallible#16
lalinsky merged 1 commit intolalinsky:mainfrom
banteg:fix/packed-any-size

Conversation

@banteg
Copy link
Copy Markdown
Contributor

@banteg banteg commented Apr 30, 2026

Summary

  • make sizeOfPackedAny() return !usize
  • fix slice detection for Zig 0.16 by using .slice
  • propagate errors from string/array size helpers
  • add coverage for string slices, array slices, and optional values

Bug

sizeOfPackedAny() delegated to helpers such as sizeOfPackedString() and sizeOfPackedArray(), which can fail for values that are too large to encode. The wrapper returned a plain usize, so it could not correctly propagate those errors.

The helper also checked ptr_info.size == .Slice, but Zig's pointer size tag is .slice. Instantiating sizeOfPackedAny() 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 all failed before the fix with .Slice and non-fallible return type errors
  • ./check.sh --ci

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 30, 2026

Warning

Rate limit exceeded

@banteg has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 3 minutes and 37 seconds before requesting another review.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 041339e5-2c48-495b-9f32-efef66c0d94a

📥 Commits

Reviewing files that changed from the base of the PR and between b4460b5 and 05eb8a7.

📒 Files selected for processing (1)
  • src/any.zig
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share
Review rate limit: 0/1 reviews remaining, refill in 3 minutes and 37 seconds.

Comment @coderabbitai help to get the list of available commands and usage tips.

@lalinsky lalinsky merged commit 34acb35 into lalinsky:main Apr 30, 2026
2 of 3 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.

2 participants