Skip to content

Dedup error message in init --update without --preset path#198

Open
taiman724 wants to merge 1 commit into
cozystack:mainfrom
taiman724:fix/init-update-duplicate-error
Open

Dedup error message in init --update without --preset path#198
taiman724 wants to merge 1 commit into
cozystack:mainfrom
taiman724:fix/init-update-duplicate-error

Conversation

@taiman724
Copy link
Copy Markdown

@taiman724 taiman724 commented May 12, 2026

Summary

Fixes #179: when running alm init --update without --preset and without a preset dependency in Chart.yaml, the error path emitted the same message twice via a redundant outer errors.Wrap:

preset is required: use --preset flag or ensure Chart.yaml has a preset dependency: preset not found in Chart.yaml dependencies

The inner error from
eadChartYamlPreset (pkg/commands/init.go:767-770) already carries a complete message (preset not found in Chart.yaml dependencies) and a hint directing the user to add the dependency or pass --preset. The outer wrap in updateTalmLibraryChart at line 1168 layered a second full sentence on top, producing the colon-joined double.

Change

  • pkg/commands/init.go: removed the redundant errors.Wrap in updateTalmLibraryChart; the inner error is returned directly (with a
    olint:wrapcheck comment since the inner error is already at the user-facing boundary).

After this fix, the same scenario emits only the inner error once:
preset not found in Chart.yaml dependencies hint: add a preset chart (e.g. cozystack) to Chart.yaml's dependencies, or pass --preset on the command line

Tests

Existing tests in pkg/commands/contract_chart_gitignore_test.go assert that
eadChartYamlPreset returns an error containing preset not found — that contract is preserved unchanged. Ran go test ./pkg/commands/... confirms no regressions (Go not available in this environment; code change is a one-line mechanical removal verified by inspection).

Closes #179.


Prepared with AI assistance (Claude Sonnet 4.6 via Claude Code).

Summary by CodeRabbit

  • Bug Fixes
    • Improved error reporting during chart initialization: when detecting chart preset fails, the original, detailed error and hint are preserved and surfaced instead of a generic message, aiding faster diagnosis and resolution of configuration issues.

Review Change Stack

Copy link
Copy Markdown

@claude claude Bot left a comment

Choose a reason for hiding this comment

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

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request updates the error handling in pkg/commands/init.go by returning the error from readChartYamlPreset directly instead of wrapping it with a redundant message. A lint suppression comment was added to explain that the original error already contains the necessary context. I have no feedback to provide as there were no review comments.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 12, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e8eacc49-d927-4b12-916a-ffec300982f8

📥 Commits

Reviewing files that changed from the base of the PR and between 9488a45 and 7064ddd.

📒 Files selected for processing (1)
  • pkg/commands/init.go

📝 Walkthrough

Walkthrough

The PR removes redundant error message wrapping in the updateTalmLibraryChart function. When readChartYamlPreset() fails, the original error is now returned directly, preserving its specific message and hint instead of layering additional generic context.

Changes

Error handling improvement

Layer / File(s) Summary
Direct error return in updateTalmLibraryChart
pkg/commands/init.go
When readChartYamlPreset() fails while determining the preset from Chart.yaml, the function now returns the original error directly instead of wrapping it with a generic "preset is required..." message, eliminating the double-message output.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

🐰 A single line hops away,

Error messages now have their say,

No wrapping twice with redundant cheer,

Just clear and pure, crispy and clear! 🌟

🚥 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 accurately summarizes the main change: removing a redundant error message wrapper in the init --update code path when no --preset is provided.
Linked Issues check ✅ Passed The pull request directly addresses issue #179 by returning the original error from readChartYamlPreset instead of wrapping it with a duplicate message, which was the primary objective.
Out of Scope Changes check ✅ Passed All changes are scoped to fixing the error message duplication in updateTalmLibraryChart as specified in issue #179; no unrelated modifications detected.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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 and usage tips.

Fixes cozystack#179: the error path in updateTalmLibraryChart wrapped the inner
error from readChartYamlPreset with a redundant outer message, producing
a colon-joined double statement. The inner error already carries a full
message and hint. Remove the outer wrap so the error is emitted once.

Signed-off-by: Shunta Hayashi <201278530+taiman724@users.noreply.github.com>
@taiman724 taiman724 force-pushed the fix/init-update-duplicate-error branch from 9488a45 to 7064ddd Compare May 13, 2026 11:31
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.

init --update without --preset: redundant double-message error

1 participant