Skip to content

fix(template): require --file or --template flag#112

Merged
kvaps merged 1 commit intomainfrom
fix/template-require-templates
Mar 19, 2026
Merged

fix(template): require --file or --template flag#112
kvaps merged 1 commit intomainfrom
fix/template-require-templates

Conversation

@kvaps
Copy link
Copy Markdown
Member

@kvaps kvaps commented Mar 19, 2026

Summary

  • Add validation in engine.Render to return a clear error when no template files are specified, instead of silently producing minimal output
  • Remove dead code branch in template.go (unreachable condition check)

Test plan

  • Run talm template -i -n X -e X without --file or --template — should show error
  • Run talm template -i -f nodes/file.yaml — should work as before
  • Run talm template -t templates/controlplane.yaml — should work as before

Summary by CodeRabbit

Bug Fixes

  • Removed validation restriction that prevented using in-place mode with alternative template specification methods
  • Added validation to ensure template sources are specified before processing, with clearer error messaging

Add validation in engine.Render to return a clear error when no template
files are specified, instead of silently producing minimal output.
Remove dead code branch in template.go (unreachable condition check).

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 19, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 45c620db-8c65-4ec0-a15d-3c48bc4f2965

📥 Commits

Reviewing files that changed from the base of the PR and between e4f5cf8 and 2417d70.

📒 Files selected for processing (2)
  • pkg/commands/template.go
  • pkg/engine/engine.go

📝 Walkthrough

Walkthrough

Validation logic for template file requirements has been reorganized: a check preventing --in-place without --file in the command handler was removed, while the engine's Render() method now validates that template sources are provided before processing, ensuring templates are set via --file or --template flags.

Changes

Cohort / File(s) Summary
Command handler validation removal
pkg/commands/template.go
Removed validation that rejected --in-place flag when template config files were not provided; validation logic relocated to engine layer.
Engine-layer validation addition
pkg/engine/engine.go
Added early validation in Render() to ensure TemplateFiles is populated; returns error if no template sources provided via --file or --template.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 Hops with glee at validation's dance,
From command to engine—what a glance!
Templates must come, no flags left bare,
Safety checks moved with utmost care! 🌟

✨ 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 fix/template-require-templates
📝 Coding Plan
  • Generate coding plan for human review comments

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.

Tip

CodeRabbit can suggest fixes for GitHub Check annotations.

Configure the reviews.tools.github-checks setting to adjust the time to wait for GitHub Checks to complete.

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the talm template command's robustness and user experience by introducing explicit error handling for missing template files. Previously, the command might have produced minimal or unexpected output without clear indication of the issue. Additionally, it cleans up an unreachable code path, contributing to overall code quality.

Highlights

  • Improved Error Handling: Implemented validation in the engine.Render function to explicitly return an error when no template files are specified, preventing silent failures and providing clear user feedback.
  • Code Cleanup: Removed a dead code branch in pkg/commands/template.go that contained an unreachable condition check, improving code maintainability.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

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 correctly removes a dead code branch and adds validation to ensure template files are provided. My feedback focuses on improving the new validation by suggesting to move it to fail-fast, which will improve efficiency by avoiding unnecessary operations when no templates are specified.

Comment on lines +244 to +246
if len(opts.TemplateFiles) == 0 {
return nil, fmt.Errorf("templates are not set for the command: please use `--file` or `--template` flag")
}
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.

medium

For better efficiency, this check should be at the beginning of the Render function. Placing it here means that chart loading and template rendering (loader.LoadDir, loadValues, eng.Render) are performed even when they are not needed, only to fail afterwards. Moving this check to the top of the function would allow it to fail-fast and avoid these unnecessary operations.

@kvaps kvaps marked this pull request as ready for review March 19, 2026 12:55
@kvaps kvaps merged commit 4732977 into main Mar 19, 2026
4 checks passed
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.

1 participant