apollographql / apollographql/router

templatizeExtraLabels doesn't stringify typically non-string values

Open
#7,204 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

raised by user
Dominant language
Rust
Stars
978
Forks
346
Avg merge
2d 22h
Merged PRs (30d)
133

Description

Describe the bug

apollographql.templatizeExtraLabels does not properly translate string values to strings when creating labels if they would otherwise be another scalar type.

For example, adding:

router:
    extraLabels:
        somelabel: "true"

would end up attempting to create this label:

somelabel: true

which would cause an error.

To Reproduce

Steps to reproduce the behavior:

  1. Create an extraLabels label that has a string value that would otherwise be a non-string value (like "true")
  2. Observe manifest creation failing with an error around labels saying something like contains non-string key in the map: true is of the type bool, expected string

Expected behavior

Manifest generation would work just fine.

Additional context

Overriding apollographql.templatizeExtraLabels with the following that uses toJson to stringify the label value solved the issue, but it could introduce breaking changes:

{{- define "apollographql.templatizeExtraLabels" -}}
{{- range $key, $value := .Values.extraLabels }}
{{ printf "%s: %s" $key (toJson (include  "apollographql.tplvalues.render" ( dict "value" $value "context" $)))}}
{{- end -}}
{{- end -}}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Locate the apollographql.templatizeExtraLabels template and reproduce the failure with an extraLabels value such as somelabel: "true". The work is done when manifest generation succeeds and the resulting label value remains a string; the issue does not name a specific file or test to run.

Written by the indexing model from the issue text.

Assessment

Tech stack
helm
Domain
devops
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.