Skip to content

fix(chart): quote secret values - #251

Merged
uniqueg merged 4 commits into
devfrom
fix/chart-quote-secrets
Nov 7, 2026
Merged

uniqueg merged 4 commits into
devfrom
fix/chart-quote-secrets

Conversation

@uniqueg

@uniqueg uniqueg commented Nov 7, 2026 •

Copy link
Copy Markdown
Member

Summary

Quote the FTP credentials and the OAuth client ID and secret in the chart Secrets, so #, : and numeric values render as strings. A helper (tesk.secretValue) renders whole numbers from values files exactly (Helm parses them as floats) and fails on numbers of 2^53 or more with a hint. Unset values still render as null. Other Secret and ConfigMap templates render no user scalars.

Closes #250

Verification

  • pytest tests/test_chart.py with helm 3.22.1: 218 passed (new tests failed before the fix).
  • ruff check and ruff format on tests: clean.
  • CI: all checks passed (CI passed gate, Chart, Chart install, Docs, Lint, Test).

Review

Full review (Helm chart): adversarial and quality reviewers, then adversarial round 2.

Declined review findings

  • Empty string now renders as an empty string instead of null (previously invalid for Kubernetes use; negligible).
  • Failure message shows the parsed float for non-integer floats of 2^53 or more (accurate; optional).

Open questions

None.

🤖 Generated with Claude Code

Summary by Sourcery

Render chart credentials safely as strings while preserving values and warning about numbers that cannot be represented exactly.

Bug Fixes:

  • Ensure FTP credentials and OAuth client credentials are always rendered as quoted YAML strings in chart Secrets, preserving special characters and numeric values.

Enhancements:

  • Preserve whole-number values from values files when rendering secrets and provide guidance when values exceed exact numeric precision.
  • Document quoting requirements for numeric and specially formatted secret values.

Documentation:

  • Document how the chart handles secret values, including large numbers, leading zeros, hexadecimal values, and exponent notation.

Tests:

  • Add chart coverage for special characters, numeric inputs, unset credentials, precision limits, and both OAuth credential key formats.

uniqueg and others added 3 commits November 7, 2026 07:39
Render the FTP credentials and the OAuth client ID and secret with
quote, so values with # or ': ' stay valid YAML and numeric values
are strings, as Kubernetes requires. Values that rendered before
render the same.

Closes #250

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Helm parses numbers in values files as floats, which quote would
render in scientific notation. Render whole numbers below 2^53 as
written, fail on larger ones with a hint, and document it. Add tests
for unset values and tidy the quoting tests.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@sourcery-ai

sourcery-ai Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Reviewer's Guide

Uses of the API

Use the secret-value helper for FTP credentials and OAuth client credentials so their rendered values remain strings.

  • charts/tesk/templates/common/oauth-client-secret.yaml L12-13
  • charts/tesk/templates/ftp/ftp-secret.yaml L12-13

Implementation

Add a helper that quotes secret values while rendering exact supported whole numbers and rejecting oversized values with guidance.

  • charts/tesk/templates/_helpers.tpl L136-154

Documentation

Document how the chart handles numeric-looking credentials and when values must be quoted or passed with --set-string.

  • docs/configuration.md L120-121

Tests

Cover quoting of tricky and numeric credentials, supported numeric rendering, unset values, and oversized-number errors.

  • tests/test_chart.py L21, L586-705

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@codecov

codecov Bot commented Nov 7, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (e459f50) to head (ed95a66).

Additional details and impacted files
@@            Coverage Diff            @@
##               dev      #251   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            1         1           
  Lines          229       229           
=========================================
  Hits           229       229           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@uniqueg
uniqueg marked this pull request as ready for review November 7, 2026 06:49

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hey - I've found 3 issues

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="charts/tesk/templates/_helpers.tpl" line_range="149" />
<code_context>
+{{- if and (lt . 9007199254740992.0) (gt . -9007199254740992.0) -}}
+{{- printf "%.0f" . | quote -}}
+{{- else -}}
+{{- fail (printf "the number %v is too large to be exact: quote it in the values file or use --set-string" .) -}}
+{{- end -}}
+{{- else -}}
</code_context>
<issue_to_address>
**Credentials leak into logs**

When an unquoted all-digit FTP or OAuth credential at or above 2^53 is supplied and Helm stderr is retained in logs readable by others, `fail` interpolates the parsed credential with `%v`, so Helm writes the secret to stderr and retained deployment or CI logs expose it to readers.

Remove the credential value from the `fail` message.
</issue_to_address>

### Comment 2
<location path="charts/tesk/templates/_helpers.tpl" line_range="149" />
<code_context>
+{{- if and (lt . 9007199254740992.0) (gt . -9007199254740992.0) -}}
+{{- printf "%.0f" . | quote -}}
+{{- else -}}
+{{- fail (printf "the number %v is too large to be exact: quote it in the values file or use --set-string" .) -}}
+{{- end -}}
+{{- else -}}
</code_context>
<issue_to_address>
**Large numbers fail**

The issue asks for every value to render as a string, but this branch fails for whole numbers at or above 2^53. Users must quote those values or use `--set-string` instead.
</issue_to_address>

### Comment 3
<location path="tests/test_chart.py" line_range="700" />
<code_context>
+    values.write_text("ftp:\n  username: 12345678901234567890\n")
+    with pytest.raises(subprocess.CalledProcessError) as error:
+        render("-f", str(values))
+    assert "too large" in error.value.stderr
+
+
</code_context>
<issue_to_address>
**Missing hint goes undetected**

When the error message says “too large” but omits the remediation guidance, `test_secret_number_too_large` at line 700 checks only for “too large,” so removing the guidance to quote the value or use `--set-string` still passes; users get no remediation hint.

Assert that stderr includes the quoting or `--set-string` guidance.
</issue_to_address>

Linked issues

#250 fix(chart): quote secret values · 3 of 4 met

# Requirement Status Notes
1 Render every secret value as a string, whatever it contains, while preserving values that already render correctly. 🟡 Partly met Values-file integers at or above 2^53 fail to render and must instead be quoted or passed with --set-string.
2 Add chart tests with #, : and numeric values for the new and old OAuth keys. ✅ Met Tests cover these values for FTP and both OAuth key forms.
3 Quote the FTP credentials and OAuth client ID and secret in the templates. ✅ Met
4 Note the behavior in the configuration reference. ✅ Met The configuration reference describes quoting, numeric values, and how to supply large numbers.

Sourcery assessment

Approval pending. 3 findings to address first.

Blocking findings: charts/tesk/templates/_helpers.tpl:149, charts/tesk/templates/_helpers.tpl:149, tests/test_chart.py:700


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread charts/tesk/templates/_helpers.tpl Resolved
Comment thread charts/tesk/templates/_helpers.tpl Resolved
Comment thread tests/test_chart.py Resolved
@uniqueg
uniqueg merged commit b874eae into dev Nov 7, 2026
21 checks passed
@uniqueg
uniqueg deleted the fix/chart-quote-secrets branch November 7, 2026 06:57
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.

fix(chart): quote secret values

1 participant