feat: optional variables — omit empty values instead of zero-filling (#51) - #52
Conversation
…51) - pruneEmptyValues/pruneAllValues strip empty non-required keys on save; required vars and unknown keys are never pruned - buildNewRow no longer backfills zero values for optional vars without a default (booleans and required vars keep today's behavior) - templateGenerator wraps non-required selector labels in hasKey guards and picks a required selector for the summary annotation (guarded fallback, no more phantom .namespace reference when a chart has no selectors) - docs/chart-authoring.md documents the empty-equals-key-absent contract and the guard convention for hand-written charts Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Preview environment torn down. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (7)
📝 WalkthroughWalkthroughOptional variable handling now omits empty optional values during persistence, centralizes new-row construction, guards optional selectors in generated templates, and documents the chart-authoring and validation contract. ChangesOptional variable contract
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant AlertUserView
participant pruneAllValues
participant saveDeployment
AlertUserView->>pruneAllValues: deployment values and schema
pruneAllValues->>pruneAllValues: remove empty optional keys
pruneAllValues-->>AlertUserView: pruned values
AlertUserView->>saveDeployment: persist pruned values
Possibly related issues
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
@coderabbitai full review |
✅ Action performedFull review finished. |
Bump version from 1.4.0 to 1.5.0 to trigger a new image build and GitHub Release via CI. Since 1.4.0: optional variables — omit empty values instead of zero-filling (#51, #52), a minor bump per this project's convention (feat commits warrant minor, not patch). Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
Implements the Phase-1 scope of #51: an empty cell on a non-required variable is represented by key absence in values.yaml, instead of being backfilled with a zero value.
Changes
src/utils/valueUtils.js(new)pruneEmptyValues(rows, vars)— strips''/null/undefinedkeys for non-required vars on save; required vars and keys not described by the schema are never prunedpruneAllValues(values, schema)— applies it per alert group;_commonand unknown groups pass through unchangedbuildNewRow(vars, commonValues)— extracted fromAlertTable.handleAdd; optional vars without a default start with no key at all (required vars and booleans keep today's zero-value backfill)AlertUserView—handleSave/handleOverviewSaveprune before POSTtemplateGenerator{{- if hasKey $row "x" }}guards (hasKey, not truthiness — stays correct for numeric enum selectors where0is legitimate); required selectors render unguardedsummaryannotation prefers a required selector; with only optional selectors it uses an inline guard; with no selectors it drops the on-clause instead of referencing a phantom.namespace(which rendered<no value>before)docs/chart-authoring.md(new) — the contract for hand-written charts: empty = key absent, never write explicitnull(Helm delete-key coalesce),hasKeyguard convention,_commonfallback semantics, promtool safety-net limitsWhy key absence (not
null)JSON Schema
typeonly validates keys that are present, so CD-sidehelm templatevalidation passes unchanged with the declared types untouched. Explicitnullis a Helm delete-key instruction during coalesce and never reliably reaches templates. See #51 for the full discussion.Testing
valueUtils, 7 new fortemplateGeneratorguards/summary; existingschemaUtils/templateGeneratorsuites unaffectednpm run lintcleanrender-api/chartDiscovery/helmUnittest(environment-dependent: helm/promtool binaries, env vars) were verified to fail identically without this changeCloses nothing on its own — #51 stays open for the E2E checklist and Future work (required enforcement, server-side ajv validation).
🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Bug Fixes
Documentation