Skip to content

feat: new deployments start empty instead of pre-filled with chart defaults - #25

Merged
HahaSula merged 2 commits into
mainfrom
feat/empty-deploy-init-clean
Jun 26, 2026
Merged

feat: new deployments start empty instead of pre-filled with chart defaults#25
HahaSula merged 2 commits into
mainfrom
feat/empty-deploy-init-clean

Conversation

@rophy

@rophy rophy commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Summary

  • POST /folders/init now writes empty arrays for each alert key instead of copying the chart's default values
  • Non-array keys (e.g. _common) are excluded from the empty deployment
  • Existing test updated + new test covering multiple alert keys and _common exclusion

Closes #23

Summary by CodeRabbit

  • Bug Fixes
    • Updated folder initialization to create cleaner deployment configuration defaults, preserving only empty array entries where needed.
    • Improved behavior when initializing from charts with no array values or no configuration file, resulting in a valid empty configuration structure.
  • Tests
    • Expanded integration coverage for initialization scenarios involving array values, non-array values, missing array keys, and missing configuration files.

…faults

Read the chart's values.yaml to discover alert key names, then write each
as an empty array to override subchart defaults. Non-array keys like
_common are excluded.

Closes #23
@rophy

rophy commented Jun 23, 2026

Copy link
Copy Markdown
Contributor Author

PR Preview Bot

Preview environment torn down.

@coderabbitai

coderabbitai Bot commented Jun 23, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The /api/v2/folders/init route now writes wrapped empty arrays for chart array keys instead of copying default array contents. The integration tests were updated and expanded to cover array keys, non-array keys, missing array keys, and missing values.yaml.

Changes

Init values generation

Layer / File(s) Summary
Derive empty array defaults
server/routes/folders.js
The /init handler loads chart defaults, keeps only top-level array keys, assigns those keys empty arrays, and wraps that reduced structure.
Update init coverage
tests/integration/folders-api.test.js
The integration tests assert empty arrays for wrapped alert keys, omit non-array keys, and cover charts with no array keys or no values.yaml.

Sequence Diagram(s)

Not applicable.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Poem

🐇 I hopped through values.yaml with glee,
and set the alert arrays all to [] for thee.
No default clutter, no extra sway,
just fresh new folders starting blank today.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly states the main change: new deployments start empty instead of inheriting chart defaults.
Linked Issues check ✅ Passed The route now writes empty arrays for alert keys and tests cover the updated init behavior requested in #23.
Out of Scope Changes check ✅ Passed The added test cases and comment cleanup are directly related to the init behavior change and not unrelated scope.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/empty-deploy-init-clean

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@HahaSula

Copy link
Copy Markdown
Contributor

The new test covers multiple array keys and _common exclusion nicely. Two edge cases worth adding:

  1. values.yaml has no array keys at all (e.g. only _common) → expected result: { 'my-alerts': {} }
  2. chart has no values.yaml → expected result: same as above

Both are currently handled by the try/catch, but explicit tests would lock down the contract.


Also noticed that the chart parameter in POST /folders/init doesn't have the same .. path traversal check as folder. Opened #33 to track it.

@rophy

rophy commented Jun 26, 2026

Copy link
Copy Markdown
Contributor Author

Added both edge-case tests in 6f1496b:

  1. No array keys (only _common) → expects { 'my-alerts': {} }
  2. No values.yaml → expects { 'my-alerts': {} }

Thanks for the catch on the chart path traversal — tracked in #33.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@server/routes/folders.js`:
- Around line 154-161: Validate the chart input in the folder route before
building chartDir so it cannot contain .. segments or be an absolute path; the
unsafe path handling currently affects the chart-related fs.readFile calls for
Chart.yaml and values.yaml. Update the chart parameter handling in the same area
as the folder checks to reject traversal attempts, and keep the rest of the
wrapValues/defaults logic unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: c54b64d8-361c-446b-8bce-2ccfe7fb19ad

📥 Commits

Reviewing files that changed from the base of the PR and between 29b151c and 6f1496b.

📒 Files selected for processing (2)
  • server/routes/folders.js
  • tests/integration/folders-api.test.js

Comment thread server/routes/folders.js
@HahaSula
HahaSula merged commit ea87c50 into main Jun 26, 2026
4 checks passed
@HahaSula
HahaSula deleted the feat/empty-deploy-init-clean branch June 26, 2026 08:39
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.

feat: new deployments should start empty instead of pre-filled with chart defaults

2 participants