Stringify 0 as axios treats it as ""

Also add a check that we don't try to log(0)
This commit is contained in:
Joe Knapper 2026-02-23 17:48:26 +00:00
parent eec4b6c380
commit 25a839bf88
2 changed files with 4 additions and 3 deletions

View file

@ -346,7 +346,8 @@ export default {
}
// Rounding to about 5 sig figs to stop weird javascript rounding.
const magnitude = Math.floor(Math.log10(Math.abs(newValue)));
const absVal = Math.abs(newValue);
const magnitude = absVal > 0 ? Math.floor(Math.log10(absVal)) : 0;
const factor = 10 ** -(Math.floor(magnitude) - 4);
this.internalValue = Math.round(newValue * factor) / factor;
},

View file

@ -56,10 +56,10 @@ export default {
"writeproperty",
false,
);
// `false` fails because axios somehow eats it!
// `false` and 0 fail because axios turns it to ""
// Other values should not be stringified or pydantic
// can't parse them.
if (value === false || value === true) {
if (value === false || value === true || value === 0) {
value = JSON.stringify(value);
}
await axios.put(url, value);