rss-bridge: render byte counts as plain decimals (1.0.2+up2025.08.05)

Teil von #157.

The null-safe fallback helpers from #99 pass values through fromYaml, which
goes over JSON and therefore parses every number as float64. Go's "%v"
switches float64 to exponential notation from about 1e6 upwards, so a bare
byte count like 1048576 turned into "1.048576e+06" - not a valid Kubernetes
quantity. The suffix check in multiplyQuantity then aborted the render with
  unsupported resource quantity suffix "e+06" in "1.048576e+06"

The second "%v" - the one printing a non-integer product - never reaches that
check and failed silently instead: with a fractional limitFactor it rendered
"1.4999985e+06" into the manifest, which only the API server rejects on apply.

Both call sites now go through a new rss-bridge.formatNumber helper that
forces decimal notation via printf "%.10f" and trims the padding zeros again;
the leading dot in the regex protects "100.0000000000" from collapsing to
"1". Strings such as "512Mi" pass through untouched.

This is the canonical fix from #157, applied verbatim with this chart's
prefix; the round-trip itself is not touched.

Note on this chart specifically: rss-bridge sets explicit memory and
ephemeral-storage limits as chart defaults, and an explicit limit always
wins, so multiplyQuantity is not reachable through this chart's values at
all - the bug was reproduced and the fix verified on a throwaway copy with
those default limits removed. The rendered output for the chart defaults and
for ci/rss-bridge/test-values.yaml is byte-identical to main.

Patch bump: no behavior and no values-schema change.
This commit is contained in:
jklein committed 2026-08-29 01:13:57 +02:00
1 parent e0e3b73202
commit e666cfed6c
2 files changed
+20 -3

No files matched your search

+1 -1
View File
@@ -5,7 +5,7 @@ icon: https://raw.githubusercontent.com/RSS-Bridge/rss-bridge/master/static/logo
type: application type: application
version: 1.0.1+up2025.08.05 version: 1.0.2+up2025.08.05
appVersion: "2025-08-05" appVersion: "2025-08-05"
maintainers: maintainers:
+19 -2
View File
@@ -63,7 +63,7 @@ Handles plain numbers ("2", "0.5", 1073741824), decimal ("1.5Gi"), binary
results are printed without a decimal point. results are printed without a decimal point.
*/}} */}}
{{- define "rss-bridge.multiplyQuantity" -}} {{- define "rss-bridge.multiplyQuantity" -}}
{{- $quantity := printf "%v" .quantity -}} {{- $quantity := include "rss-bridge.formatNumber" .quantity -}}
{{- $number := regexFind "^[0-9]+(\\.[0-9]+)?" $quantity -}} {{- $number := regexFind "^[0-9]+(\\.[0-9]+)?" $quantity -}}
{{- if not $number -}} {{- if not $number -}}
{{- fail (printf "cannot parse resource quantity %q" $quantity) -}} {{- fail (printf "cannot parse resource quantity %q" $quantity) -}}
@@ -76,7 +76,24 @@ results are printed without a decimal point.
{{- if eq $product (floor $product) -}} {{- if eq $product (floor $product) -}}
{{- printf "%d%s" (int64 $product) $suffix -}} {{- printf "%d%s" (int64 $product) $suffix -}}
{{- else -}} {{- else -}}
{{- printf "%v%s" $product $suffix -}} {{- printf "%s%s" (include "rss-bridge.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 "rss-bridge.formatNumber" -}}
{{- if kindIs "float64" . -}}
{{- regexReplaceAll "\\.?0+$" (printf "%.10f" .) "" -}}
{{- else -}}
{{- printf "%v" . -}}
{{- end -}} {{- end -}}
{{- end -}} {{- end -}}