EnergySystemsModellingLab / EnergySystemsModellingLab/MUSE2

Unclear "Invalid digit found in string" error for invalid process lifetimes

Open
#1,439 1 comment 0 reactions 0 assignees View on GitHub
bug
Dominant language
Rust
Stars
8
Forks
5
Avg merge
1d 2m
Merged PRs (30d)
37

Description

Process lifetimes must take integer values (i.e. whole number of years). If float values (e.g. 15.1) or negative values (e.g. -15) are provided, there should be a clear error message saying that only positive integer values are allowed. Instead, we currently get a rather cryptic "Invalid digit found in string" message. Presumably this comes from serde trying to deserialise into a `u32`. Perhaps instead we need to deserialise into a float, do the validation checks manually, then convert to `u32` (or some other approach).

Side note, but the tests are currently only checking for the presence of an error, not the exact error message. We should fix this up as well.

Contributor guide

Open the contributing guide

Research direction

Locate the process-lifetime deserialization and its existing tests, then run those tests to reproduce the cryptic error for float and negative values. Make invalid values produce a clear message that only positive integers are allowed, and update the tests to assert the exact message.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
65/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.