Skip to content

Comments

Fix missing support for 128-bit integers#731

Open
tyranron wants to merge 2 commits intorust-cli:mainfrom
tyranron:fix-parsing-into-i128
Open

Fix missing support for 128-bit integers#731
tyranron wants to merge 2 commits intorust-cli:mainfrom
tyranron:fix-parsing-into-i128

Conversation

@tyranron
Copy link
Contributor

@tyranron tyranron commented Feb 4, 2026

Complements #178
Related to #161

Synopsis

At the moment trying to deserialize Config into a struct with u128/i128 errors:

thread 'conf::conf_parse_spec::reads_from_yaml_file' (65705764) panicked at src/conf.rs:688:41:
Failed to parse config: u128 is not supported for key `db.tigerbeetle.cluster_id`

This happens even if the parsed value is small and fits into other integers.

Solution

This PR wires the Value's i128/u128 functionality into Deserializer/Serializer implementations.

@tyranron tyranron force-pushed the fix-parsing-into-i128 branch from 3ca2522 to f99d86e Compare February 4, 2026 13:41
@coveralls
Copy link

coveralls commented Feb 4, 2026

Pull Request Test Coverage Report for Build 21992788757

Details

  • 1 of 10 (10.0%) changed or added relevant lines in 3 files are covered.
  • 10 unchanged lines in 2 files lost coverage.
  • Overall coverage decreased (-0.4%) to 63.834%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/value.rs 0 2 0.0%
src/de.rs 1 4 25.0%
src/ser.rs 0 4 0.0%
Files with Coverage Reduction New Missed Lines %
src/ser.rs 3 36.21%
src/de.rs 7 85.28%
Totals Coverage Status
Change from base Build 21686348660: -0.4%
Covered Lines: 939
Relevant Lines: 1471

💛 - Coveralls

@tyranron tyranron force-pushed the fix-parsing-into-i128 branch 2 times, most recently from e06fd8c to 6981823 Compare February 4, 2026 13:47
@tyranron
Copy link
Contributor Author

tyranron commented Feb 4, 2026

CI error with failed coverage publishing is not relevant to this PR. Everything else made green.

src/ser.rs Outdated
Comment on lines 111 to 126
fn serialize_i128(self, v: i128) -> Result<Self::Ok> {
if v > i64::MAX.into() {
Err(ConfigError::Message(format!(
"value {} is greater than the max {}",
v,
i64::MAX
)))
} else if v < i64::MIN.into() {
Err(ConfigError::Message(format!(
"value {} is less than the min {}",
v,
i64::MIN
)))
} else {
self.serialize_i64(v as i64)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we checking the ranges rather than serializing as a primitive?

Copy link
Contributor Author

@tyranron tyranron Feb 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@epage I don't know. I did repeat the logic that was already there for the serialize_u64(). It seems strange to me too, but I can only speculate that it's there for compatibility with JSON integer types, or something.

Personally, I don't see any value in it. But changing this would be a subtle breaking change, so seemed to be out of scope for this PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fixed the serialize_u64 logic in #732.

If its safe to introduce this code and it is safe to remove error cases (which it generally is), then it seems to be safe to make this change. If you have a concrete concern over how this would break someone, I would be interested in hearing it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@epage

I fixed the serialize_u64 logic in #732.

Nice! I've updated the code and the tests.

If you have a concrete concern over how this would break someone, I would be interested in hearing it.

As I've said before, only speculations so far:
That check was there for some reason. So maybe it was added to disallow serializing configs, which couldn't be parsed by other languages (such as JS). And so, maybe some code using the config crate may rely on that hidden contract.

Since this is a hidden behavior change that may, probably, cause some breaks, I think it should be documented very well in the CHANGELOG, and the crate version bumped to 0.16.0. Just to be safe.

@tyranron tyranron force-pushed the fix-parsing-into-i128 branch from 8e0d092 to af36c24 Compare February 4, 2026 21:52
@tyranron tyranron force-pushed the fix-parsing-into-i128 branch from af36c24 to 0593ae2 Compare February 13, 2026 15:38
@tyranron tyranron requested a review from epage February 13, 2026 15:44
@tyranron
Copy link
Contributor Author

@epage done.

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.

3 participants