From ce73bc1111fd0a813391c952ad9008188e9aa776 Mon Sep 17 00:00:00 2001 From: jklein Date: Sat, 29 Aug 2026 01:08:07 +0200 Subject: [PATCH] freesailarr: no exponential notation in computed limits (3.0.2+up1.0.0) The null-safe fallback helpers from #99 route values through fromYaml, which parses every number as float64. Go's "%v" switches float64 to exponential notation from about 1e6 upwards, so a bare byte count like 1048576 reached the suffix check inside multiplyQuantity as "1.048576e+06" and the render aborted with `unsupported resource quantity suffix "e+06"`. Both printf "%v" sites in multiplyQuantity now go through a new formatNumber helper that forces plain decimal notation and trims the padded zeros. The second site is the quiet half of the bug: a fractional limitFactor together with a bare number produced no error at all, just an invalid quantity such as "1.4999985e+06" that only the API server rejects on apply. limitFactor is typed "number" in this chart's values.schema.json, so a fractional factor is an ordinary, schema-valid input. All ten resource paths of the stack are affected and were verified one by one (gluetun, qbittorrent and its configInit init container, prowlarr, flaresolverr, radarr, recyclarr, sonarr, seerr, bazarr). The VPN, firewall and container structure is untouched: rendering the chart with its default values is byte-identical to main. Teil von #157 --- freesailarr/Chart.yaml | 2 +- freesailarr/templates/_helpers.tpl | 21 +++++++++++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/freesailarr/Chart.yaml b/freesailarr/Chart.yaml index 7b261f3..db2b74b 100644 --- a/freesailarr/Chart.yaml +++ b/freesailarr/Chart.yaml @@ -8,7 +8,7 @@ description: A Helm chart to deploy a Wireguard-tunneled media automation stack type: application -version: 3.0.1+up1.0.0 +version: 3.0.2+up1.0.0 # The chart's own version marker, freely chosen and tied to no upstream. The # stack bundles nine independently versioned projects, so there is no single # "app version" to track here. diff --git a/freesailarr/templates/_helpers.tpl b/freesailarr/templates/_helpers.tpl index a49f2c4..93a2ef4 100644 --- a/freesailarr/templates/_helpers.tpl +++ b/freesailarr/templates/_helpers.tpl @@ -67,7 +67,7 @@ Handles plain numbers ("2", "0.5", 1073741824), decimal ("1.5Gi"), binary results are printed without a decimal point. */}} {{- define "freesailarr.multiplyQuantity" -}} -{{- $quantity := printf "%v" .quantity -}} +{{- $quantity := include "freesailarr.formatNumber" .quantity -}} {{- $number := regexFind "^[0-9]+(\\.[0-9]+)?" $quantity -}} {{- if not $number -}} {{- fail (printf "cannot parse resource quantity %q" $quantity) -}} @@ -80,7 +80,24 @@ results are printed without a decimal point. {{- if eq $product (floor $product) -}} {{- printf "%d%s" (int64 $product) $suffix -}} {{- else -}} -{{- printf "%v%s" $product $suffix -}} +{{- printf "%s%s" (include "freesailarr.formatNumber" $product) $suffix -}} +{{- end -}} +{{- end -}} + +{{/* +Render a number as a plain decimal string, never in exponential notation. + +Why this exists (issue #157): the null-safe fallback helpers pass values +through fromYaml, which parses every number as float64. Go's "%v" switches +float64 to exponential notation from about 1e6 upwards, so a bare byte count +like 1048576 became "1.048576e+06" - not a valid Kubernetes quantity, and the +render aborted. Strings ("512Mi") are passed through untouched. +*/}} +{{- define "freesailarr.formatNumber" -}} +{{- if kindIs "float64" . -}} +{{- regexReplaceAll "\\.?0+$" (printf "%.10f" .) "" -}} +{{- else -}} +{{- printf "%v" . -}} {{- end -}} {{- end -}}