Repository navigation
fix(acl): preserve Number::Int on serde_json round-trip - #15481
Merged
Legend-Master merged 2 commits intoJun 5, 2026
Merged
Legend-Master merged 2 commits into
Legend-Master merged 2 commits into
Conversation
From<serde_json::Value> for Value was checking as_f64() first, which succeeds for any integer that fits in an f64, causing all integer values to be silently coerced to Number::Float on deserialization. Fix the check order to prefer as_i64() first, then as_u64() (falling back to Float for values above i64::MAX to avoid silent wrapping), and only using as_f64() for genuine floating-point numbers. Fixes tauri-apps#15480
thanhtoantnt
force-pushed
the
fix/acl-number-int-coerced-to-float
branch
from
June 5, 2026 02:21
31712f9 to
52f3d1a
Compare
| serde_json::Value::Null => Value::Null, | ||
| serde_json::Value::Bool(b) => Value::Bool(b), | ||
| serde_json::Value::Number(n) => Value::Number(if let Some(f) = n.as_f64() { | ||
| serde_json::Value::Number(n) => Value::Number(if let Some(i) = n.as_i64() { |
Contributor
There was a problem hiding this comment.
@lucasfernog do you still remember where is this never mind, it's used in migration and capability builderFrom<serde_json:Value> for Value impl is used? I can't seem to find any and this conversion implementation depends heavily on how it was used
I think should look into just use serde_json:Value here in v3
From<serde_json::Value> for Value was checking as_f64() first, which succeeds for any integer that fits in an f64, causing all integer values to be silently coerced to Number::Float on deserialization. Fix the check order to prefer as_i64() first, then as_u64() (cast to i64, wrapping for values above i64::MAX), and only using as_f64() for genuine floating-point numbers. Fixes tauri-apps#15480
Contributor
Package Changes Through 1e67492There are 5 changes which include tauri-utils with patch, tauri with patch, tauri-bundler with patch, tauri-cli with patch, @tauri-apps/cli with patch Planned Package VersionsThe following package releases are the planned based on the context of changes in this pull request.
Add another change file through the GitHub UI by following this link. Read about change files or the docs at github.com/jbolda/covector |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
closes #15480
What changed
From<serde_json::Value> for Value in crates/tauri-utils/src/acl/value.rs was checking as_f64() before as_i64(). Because serde_json::Number::as_f64() succeeds for any integer that
fits in an f64, every integer JSON number was silently deserialized as Number::Float — the as_i64() branch was never reached for typical values.
The check order is now:
This matches serde_json's own visitor convention of preferring integer representations when the number has no decimal component.
Impact