Skip to content

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

@vliska

Description

@vliska

Name and Version

bitnami/common 2.2.0

What steps will reproduce the bug?

When using common.names.chart for label (which is normal), following error can happen:

message: 'Helm upgrade failed for release <namespace>/<app-with-particular-length>
  with chart <app-with-particular-length>@2.1.13-SNAPSHOT-20260126-095732+ba14b1c07afe:
  cannot patch "<app-with-particular-length>" with kind Service: Service "<app-with-particular-length>"
  is invalid: metadata.labels: Invalid value: "<app-with-particular-length>-2.1.13-SNAPSHOT-20260126-095732_":
  a valid label must be an empty string or consist of alphanumeric characters,

This is combination of flux OCIRepository (which adds + character) and exact length of application name + version + timestamp.

{{- define "common.names.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

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

Function correctly replaces + with _, but the _ ends up being last character (63rd), which is not allowed in labels/DNS.

Correction is e.g. to add | trimSuffix "_".

Are you using any custom parameters or values?

No response

What is the expected behavior?

_ not being last character after trimming

What do you see instead?

_ is last character after trimming, which is not DNS conform (can't be used in labels, names, etc.)

Additional information

No response

Metadata

Metadata

Assignees

Labels

commontech-issuesThe user has a technical issue about an applicationtriageTriage is needed

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions