Skip to content

[bitnami/common] Sanitize truncated chart label values#36558

Merged
carrodher merged 1 commit into
bitnami:mainfrom
pschiffe:main
Jun 29, 2026
Merged

[bitnami/common] Sanitize truncated chart label values#36558
carrodher merged 1 commit into
bitnami:mainfrom
pschiffe:main

Conversation

@pschiffe

Copy link
Copy Markdown
Contributor

Description of the change

This updates the bitnami/common label helpers so generated Kubernetes label values remain valid after SemVer build metadata is normalized and truncated.

Specifically:

  • Adds a shared common.labels.value helper.
  • Applies it to helm.sh/chart.
  • Applies it to app.kubernetes.io/version.
  • Preserves the existing + to _ conversion and 63-character truncation.
  • Trims trailing non-alphanumeric characters after truncation.

This prevents labels such as helm.sh/chart from ending in _ when a long chart version with build metadata is truncated.

Benefits

Charts can use long SemVer versions containing build metadata without rendering Kubernetes-invalid labels.

Example fixed case:

  grid-checkout-internal-gateway@2.1.13-SNAPSHOT-20260126-095732+ba14b1c07afe

Previously this could truncate to a label ending in _, which Kubernetes rejects. The helper now trims that trailing invalid character while preserving the valid prefix.

Possible drawbacks

If a generated helm.sh/chart or app.kubernetes.io/version label would previously have ended with a non-alphanumeric character after truncation, the rendered label value is now slightly shorter. The chart version and appVersion themselves are unchanged.

Applicable issues

Additional information

Validation performed:

  • Rendered a temporary consumer chart using a long chart version with build metadata.
  • Verified rendered helm.sh/chart and app.kubernetes.io/version labels:
    • are no longer than 63 characters
    • match Kubernetes label value syntax
    • end with an alphanumeric character
  • Ran:
  helm lint bitnami/common

Checklist

  • Chart version bumped in Chart.yaml according to semver. This is not necessary when the changes only affect README.md files.
  • Variables are documented in the values.yaml and added to the README.md using readme-generator-for-helm
  • Title of the pull request follows this pattern [bitnami/<name_of_the_chart>] Descriptive title
  • All commits signed off and in agreement of Developer Certificate of Origin (DCO)

Ensure helm.sh/chart and app.kubernetes.io/version labels still end with
an alphanumeric character after replacing + and truncating to
Kubernetes' 63-character label limit.

Resolves bitnami#36452

Signed-off-by: Peter Schiffer <3899107+pschiffe@users.noreply.github.com>
@github-actions github-actions Bot added common triage Triage is needed labels Jun 24, 2026
@github-actions github-actions Bot requested a review from javsalgar June 24, 2026 21:17
@github-actions github-actions Bot removed the triage Triage is needed label Jun 26, 2026
@github-actions github-actions Bot removed the request for review from javsalgar June 26, 2026 08:06
@github-actions github-actions Bot requested a review from dgomezleon June 26, 2026 08:06

@dgomezleon dgomezleon left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks for contributing

@dgomezleon dgomezleon enabled auto-merge (squash) June 29, 2026 09:57
@carrodher carrodher disabled auto-merge June 29, 2026 11:39
@carrodher carrodher merged commit f163ae8 into bitnami:main Jun 29, 2026
18 of 21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

common.names.chart not DNS conform in special case (63 chars + _)

5 participants