From cc1e7bb53e8728e2eb1bb751d22e1cc6306add2d Mon Sep 17 00:00:00 2001 From: jklein Date: Sat, 29 Aug 2026 00:58:17 +0200 Subject: [PATCH] apache-tika: render byte counts as plain decimals (10.0.1+up3.3.1.0.full) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 reached multiplyQuantity as "1.048576e+06" and the suffix check aborted the render: unsupported resource quantity suffix "e+06" in "1.048576e+06" The second "%v" — the output of a non-integer product — never reaches that check, so it produced an invalid quantity without any abort. In this chart that value is caught one step later by NOTES.txt, which feeds the computed memory limit back into multiplyQuantity: the Deployment still carried memory: "1.4999985e+06" and the error pointed at NOTES.txt:54 instead of the real cause. Both places now go through a new formatNumber helper, which forces decimal notation via "%.10f" and trims the padded zeros again; strings such as "512Mi" pass through untouched. This is the canonical fix from #157, taken over verbatim with this chart's prefix, because multiplyQuantity is the same copy in every chart. Chart defaults render unchanged. Patch bump: bug fix only, no behavior and no values-schema change; appVersion stays. --- apache-tika/Chart.yaml | 2 +- apache-tika/templates/_helpers.tpl | 21 +++++++++++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/apache-tika/Chart.yaml b/apache-tika/Chart.yaml index 7ffda85..f440e3b 100644 --- a/apache-tika/Chart.yaml +++ b/apache-tika/Chart.yaml @@ -5,5 +5,5 @@ icon: https://www.apache.org/logos/res/tika/default.png type: application -version: 10.0.0+up3.3.1.0.full +version: 10.0.1+up3.3.1.0.full appVersion: "3.3.1.0-full" diff --git a/apache-tika/templates/_helpers.tpl b/apache-tika/templates/_helpers.tpl index 9609cb1..da53c1a 100644 --- a/apache-tika/templates/_helpers.tpl +++ b/apache-tika/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 "apache-tika.multiplyQuantity" -}} -{{- $quantity := printf "%v" .quantity -}} +{{- $quantity := include "apache-tika.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 "apache-tika.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 "apache-tika.formatNumber" -}} +{{- if kindIs "float64" . -}} +{{- regexReplaceAll "\\.?0+$" (printf "%.10f" .) "" -}} +{{- else -}} +{{- printf "%v" . -}} {{- end -}} {{- end -}}