chore(deps): update rust crate toml to 0.9#3
Conversation
📝 WalkthroughWalkthroughMultiple crate dependencies are upgraded, specifically Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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. Comment |
|
@coderabbitai review |
1 similar comment
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Fix all issues with AI agents
In `@crates/tauri-utils/Cargo.toml`:
- Line 37: The toml 0.9 dependency only enables "parse" but the crate uses
serde-gated APIs (toml::Value, toml::de::Error, toml::from_str()), so update the
toml dependency entry to enable the "serde" feature as well (e.g., features =
["parse", "serde"]) so those APIs are available and the crate compiles; locate
the toml line in Cargo.toml and add "serde" to the features array.
In `@crates/tauri-utils/src/config.rs`:
- Line 180: BundleType::Flatpak is rendered as "Flatpak" in the Display impl
while other BundleType variants are lowercase, causing inconsistent serialized
output because Serialize uses Display; update the Display implementation for
BundleType (the match arm for Flatpak) to return the lowercase "flatpak" to
match the casing of the other variants and ensure consistent serialization.
In `@crates/tauri-utils/src/config/parse.rs`:
- Around line 384-391: The TOML parser in do_parse_toml currently maps
toml::from_str errors to ConfigError::FormatJson; change it to map parse
failures to ConfigError::FormatToml instead, preserving the path and converting
the toml error to a message (e.g., error.to_string()) for the
ConfigError::FormatToml error payload so users see a TOML-specific parse error;
update the map_err closure in do_parse_toml to construct ConfigError::FormatToml
with path.into() and the converted error text.
| ctor = "0.2" | ||
| json5 = { version = "0.4", optional = true } | ||
| toml = { version = "0.8", features = ["parse"] } | ||
| toml = { version = "0.9", features = ["parse"] } |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Search for toml usage patterns in tauri-utils
rg -n "toml::" crates/tauri-utils/src/ -A 2 -B 2Repository: agentic-review-benchmarks/tauri-combined-coderabbit
Length of output: 4320
🏁 Script executed:
#!/bin/bash
# Also check for any toml module imports
rg -n "use toml" crates/tauri-utils/src/ -A 2 -B 2Repository: agentic-review-benchmarks/tauri-combined-coderabbit
Length of output: 402
🏁 Script executed:
#!/bin/bash
# Check the actual Cargo.toml to see context around the dependency
cat -n crates/tauri-utils/Cargo.toml | sed -n '30,45p'Repository: agentic-review-benchmarks/tauri-combined-coderabbit
Length of output: 764
🌐 Web query:
toml crate 0.9 breaking changes from 0.8 API compatibility
💡 Result:
Key breaking / API-compat changes when moving toml 0.8 → 0.9:
-
Serde is no longer unconditional: in 0.8,
serdeis a required dependency andtoml::Value/toml::Tableare always available (behindparse/displayfor parsing/printing). In 0.9,serdebecomes an optional feature, andValue,Table,sermodule, andfrom_str/to_stringre-exports are gated behindfeature = "serde". If you compile withdefault-features = false, code usingtoml::Value/toml::Tablewill break unless you enableserde. [1][2][3][4] -
Feature set / defaults changed:
- 0.8 defaults:
default = ["parse", "display"]. [1] - 0.9 defaults:
default = ["std", "serde", "parse", "display"]and adds new feature structure (std,serde, plusdebug/fast_hash). [2]
- 0.8 defaults:
-
Parser / writer backend changed:
- 0.8
parse/displayare implemented via an optional dependency ontoml_edit. [1] - 0.9
parseusestoml_parser(+winnow) anddisplayusestoml_writer(and no longer depends ontoml_edit). [2]
- 0.8
-
preserve_ordernow impliesstdin 0.9 (preserve_order = ["dep:indexmap", "std"]), while in 0.8 it was just["indexmap"](no explicitstdrequirement). [1][2] -
unboundedfeature semantics changed: in 0.8 it forwards totoml_edit?/unbounded; in 0.9 it’s defined as an empty feature (unbounded = []) (i.e., it no longer enables a backend capability the way it used to). [1][2]
How to keep behavior closest to 0.8:
- If you previously relied on
tomlworking withdefault-features = false, you likely now want something like:features = ["serde", "parse", "display"](andstdif you need it /preserve_order).
- Otherwise, using default features on 0.9 is the simplest path since it includes
std + serde + parse + displayby default. [2]
Sources: 0.8.23 Cargo features/deps [1], 0.9.0 Cargo features/deps [2], and lib.rs public re-exports showing new serde gating in 0.9 vs 0.8 [3][4].
References:
[1] https://docs.rs/crate/toml/0.8.23/source/Cargo.toml.orig
[2] https://docs.rs/crate/toml/0.9.0/source/Cargo.toml.orig
[3] https://docs.rs/crate/toml/0.8.23/source/src/lib.rs
[4] https://docs.rs/crate/toml/0.9.0/source/src/lib.rs
Add serde feature to toml 0.9 dependency.
The upgrade to toml 0.9 made serde an optional feature (it was unconditional in 0.8). The current configuration uses only features = ["parse"], but the code relies on serde-gated APIs like toml::Value, toml::de::Error, and toml::from_str(). This will cause compilation failures. Update to features = ["parse", "serde"].
🤖 Prompt for AI Agents
In `@crates/tauri-utils/Cargo.toml` at line 37, The toml 0.9 dependency only
enables "parse" but the crate uses serde-gated APIs (toml::Value,
toml::de::Error, toml::from_str()), so update the toml dependency entry to
enable the "serde" feature as well (e.g., features = ["parse", "serde"]) so
those APIs are available and the crate compiles; locate the toml line in
Cargo.toml and add "serde" to the features array.
| Self::Nsis => "nsis", | ||
| Self::App => "app", | ||
| Self::Dmg => "dmg", | ||
| Self::Flatpak => "Flatpak", |
There was a problem hiding this comment.
Inconsistent casing in Display impl for Flatpak.
BundleType::Flatpak displays as "Flatpak" (capitalized), while all other variants use lowercase ("deb", "rpm", "appimage", etc.). Since Serialize uses Display (line 191), this creates inconsistent serialization output.
✏️ Suggested fix for consistency
Self::App => "app",
Self::Dmg => "dmg",
- Self::Flatpak => "Flatpak",
+ Self::Flatpak => "flatpak",
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| Self::Flatpak => "Flatpak", | |
| Self::App => "app", | |
| Self::Dmg => "dmg", | |
| Self::Flatpak => "flatpak", | |
| } |
🤖 Prompt for AI Agents
In `@crates/tauri-utils/src/config.rs` at line 180, BundleType::Flatpak is
rendered as "Flatpak" in the Display impl while other BundleType variants are
lowercase, causing inconsistent serialized output because Serialize uses
Display; update the Display implementation for BundleType (the match arm for
Flatpak) to return the lowercase "flatpak" to match the casing of the other
variants and ensure consistent serialization.
| #[cfg(feature = "config-toml")] | ||
| fn do_parse_toml<D: DeserializeOwned>(raw: &str, path: &Path) -> Result<D, ConfigError> { | ||
| ::toml::from_str(raw).map_err(|error| ConfigError::FormatToml { | ||
| // Parse using toml 0.9's from_str which returns different error types | ||
| ::toml::from_str(raw).map_err(|error| ConfigError::FormatJson { | ||
| path: path.into(), | ||
| error: Box::new(error), | ||
| error: serde_json::Error::custom(error.to_string()), | ||
| }) | ||
| } |
There was a problem hiding this comment.
Critical: TOML parse errors incorrectly reported as JSON errors.
The TOML parse error is being mapped to ConfigError::FormatJson instead of ConfigError::FormatToml. This will produce misleading error messages to users—when a Tauri.toml file fails to parse, they'll see "unable to parse JSON Tauri config file" (from line 83).
The ConfigError::FormatToml variant exists at lines 103-112 and should be used here.
🐛 Proposed fix
#[cfg(feature = "config-toml")]
fn do_parse_toml<D: DeserializeOwned>(raw: &str, path: &Path) -> Result<D, ConfigError> {
// Parse using toml 0.9's from_str which returns different error types
- ::toml::from_str(raw).map_err(|error| ConfigError::FormatJson {
+ ::toml::from_str(raw).map_err(|error| ConfigError::FormatToml {
path: path.into(),
- error: serde_json::Error::custom(error.to_string()),
+ error: Box::new(error),
})
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| #[cfg(feature = "config-toml")] | |
| fn do_parse_toml<D: DeserializeOwned>(raw: &str, path: &Path) -> Result<D, ConfigError> { | |
| ::toml::from_str(raw).map_err(|error| ConfigError::FormatToml { | |
| // Parse using toml 0.9's from_str which returns different error types | |
| ::toml::from_str(raw).map_err(|error| ConfigError::FormatJson { | |
| path: path.into(), | |
| error: Box::new(error), | |
| error: serde_json::Error::custom(error.to_string()), | |
| }) | |
| } | |
| #[cfg(feature = "config-toml")] | |
| fn do_parse_toml<D: DeserializeOwned>(raw: &str, path: &Path) -> Result<D, ConfigError> { | |
| // Parse using toml 0.9's from_str which returns different error types | |
| ::toml::from_str(raw).map_err(|error| ConfigError::FormatToml { | |
| path: path.into(), | |
| error: Box::new(error), | |
| }) | |
| } |
🤖 Prompt for AI Agents
In `@crates/tauri-utils/src/config/parse.rs` around lines 384 - 391, The TOML
parser in do_parse_toml currently maps toml::from_str errors to
ConfigError::FormatJson; change it to map parse failures to
ConfigError::FormatToml instead, preserving the path and converting the toml
error to a message (e.g., error.to_string()) for the ConfigError::FormatToml
error payload so users see a TOML-specific parse error; update the map_err
closure in do_parse_toml to construct ConfigError::FormatToml with path.into()
and the converted error text.
Benchmark PR from agentic-review-benchmarks#3
Summary by CodeRabbit
New Features
Chores