Skip to content

fix(config): handle numeric, boolean, and falsy env var values#169

Open
camjay wants to merge 2 commits intoPortkey-AI:mainfrom
camjay:fix/config-tostring-quote
Open

fix(config): handle numeric, boolean, and falsy env var values#169
camjay wants to merge 2 commits intoPortkey-AI:mainfrom
camjay:fix/config-tostring-quote

Conversation

@camjay
Copy link
Copy Markdown

@camjay camjay commented Mar 24, 2026

Numeric and boolean values in environment.data (e.g., PORT: 8787, REDIS_TLS_ENABLED: false) fail b64enc in Secret mode and render as unquoted YAML in ConfigMap mode.

Additionally, the existing {{- if $val }} guard treats false, 0, and "" as falsy — encoding them as empty strings instead of their actual values.

Fixes:

  • Add toString before b64enc (Secret) and toString | quote (ConfigMap)
  • Change if $val to if not (kindIs "invalid" $val) so falsy values are properly encoded

See also #173 which adds CI to validate chart templates on PRs.

@camjay camjay force-pushed the fix/config-tostring-quote branch from 8dfc67b to 533ce2f Compare March 24, 2026 22:05
Numeric and boolean values in environment.data (e.g., PORT: 8787,
REDIS_TLS_ENABLED: false) fail b64enc in Secret mode and render as
unquoted YAML in ConfigMap mode.

Fixes:
- Add toString before b64enc (Secret) and toString|quote (ConfigMap)
- Change the if guard from `if $val` to `if not (kindIs "invalid" $val)`
  so that falsy values (false, 0, "") are properly encoded instead of
  being treated as empty
@camjay camjay force-pushed the fix/config-tostring-quote branch from 533ce2f to ff3c1f3 Compare March 24, 2026 22:48
@camjay camjay changed the title fix(config): use toString before b64enc and quote fix(config): handle numeric, boolean, and falsy env var values Mar 24, 2026
@camjay camjay marked this pull request as ready for review March 25, 2026 01:08
@sk-portkey sk-portkey requested a review from Copilot March 25, 2026 09:50
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates the portkey-gateway Helm chart environment resource template to correctly render numeric/boolean and falsy values in both Secret and ConfigMap modes, avoiding template failures and YAML type surprises.

Changes:

  • Convert env var values to strings before base64 encoding when rendering a Secret.
  • Quote ConfigMap values after converting to strings to ensure they are always YAML strings.
  • Replace the if $val guard with an invalid-kind check so false, 0, and "" are preserved.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@sk-portkey
Copy link
Copy Markdown
Contributor

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants