Skip to content

Conversation

@samtholiya
Copy link
Collaborator

@samtholiya samtholiya commented Nov 5, 2025

what

why

references

#1619

Summary by CodeRabbit

  • Refactor

    • Internal refactoring improved code consistency across markdown rendering utilities through updated parameter handling approaches.
  • Tests

    • Updated tests to align with internal refactoring changes.

@github-actions github-actions bot added the size/s Small size PR label Nov 5, 2025
@github-actions
Copy link

github-actions bot commented Nov 5, 2025

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@samtholiya samtholiya added the patch A minor, backward compatible change label Nov 5, 2025
@codecov
Copy link

codecov bot commented Nov 5, 2025

Codecov Report

❌ Patch coverage is 84.61538% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 69.87%. Comparing base (af04688) to head (575bfd0).
⚠️ Report is 14 commits behind head on main.

Files with missing lines Patch % Lines
internal/tui/templates/templater.go 0.00% 2 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1755      +/-   ##
==========================================
- Coverage   69.89%   69.87%   -0.03%     
==========================================
  Files         398      398              
  Lines       36487    36487              
==========================================
- Hits        25503    25495       -8     
- Misses       8675     8683       +8     
  Partials     2309     2309              
Flag Coverage Δ
unittests 69.87% <84.61%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
cmd/root.go 51.06% <100.00%> (ø)
errors/error_funcs.go 81.39% <100.00%> (ø)
internal/tui/templates/help_printer.go 68.00% <100.00%> (ø)
internal/tui/utils/utils.go 53.33% <100.00%> (ø)
pkg/ui/markdown/renderer.go 82.00% <100.00%> (ø)
pkg/ui/markdown/styles.go 80.18% <100.00%> (ø)
pkg/utils/markdown_utils.go 90.00% <100.00%> (ø)
internal/tui/templates/templater.go 26.62% <0.00%> (ø)

... and 3 files with indirect coverage changes

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

@samtholiya samtholiya marked this pull request as ready for review November 5, 2025 22:34
@samtholiya samtholiya requested a review from a team as a code owner November 5, 2025 22:34
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 5, 2025

Warning

Rate limit exceeded

@osterman has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 20 minutes and 47 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between d303294 and 575bfd0.

📒 Files selected for processing (1)
  • cmd/root.go (1 hunks)
📝 Walkthrough

Walkthrough

Systematic refactoring converting AtmosConfiguration parameters from value to pointer semantics across markdown utilities and renderer modules. Function signatures updated along with all corresponding call sites in implementations, templates, and tests. No control-flow or behavior changes; only calling convention modifications.

Changes

Cohort / File(s) Summary
Core Signature Changes
pkg/utils/markdown_utils.go, pkg/ui/markdown/renderer.go, pkg/ui/markdown/styles.go
Updated public function signatures to accept pointers to AtmosConfiguration: InitializeMarkdown, NewRenderer, NewTerminalMarkdownRenderer, and GetDefaultStyle now take *schema.AtmosConfiguration instead of schema.AtmosConfiguration.
Command & Root Call Sites
cmd/root.go
Updated InitializeMarkdown call to pass pointer: utils.InitializeMarkdown(&atmosConfig) instead of value.
Template & TUI Call Sites
internal/tui/templates/help_printer.go, internal/tui/templates/templater.go, internal/tui/utils/utils.go
Updated NewTerminalMarkdownRenderer and GetDefaultStyle calls to pass pointers to AtmosConfiguration configuration objects.
Test Files - Core Markdown
pkg/ui/markdown/markdown_test.go, pkg/ui/markdown/renderer_test.go
Updated test fixtures and call sites to construct and pass &schema.AtmosConfiguration{} pointers instead of values across NewRenderer, NewTerminalMarkdownRenderer, and GetDefaultStyle invocations.
Test Files - Utilities
pkg/utils/markdown_utils_test.go, pkg/telemetry/utils_test.go, errors/error_funcs_test.go
Updated test calls to InitializeMarkdown and NewTerminalMarkdownRenderer to pass pointer arguments aligned with signature changes.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

The refactoring follows a consistent pattern across all files—converting value-based configuration parameters to pointer-based ones. While the scope spans multiple files, the homogeneous nature of changes (repetitive application of the same transformation) makes review straightforward. Key areas requiring attention:

  • Confirm pointer semantics are consistently applied at all call sites
  • Verify no nil-dereference risks introduced without corresponding nil-checks
  • Ensure test mocks and fixtures properly reflect pointer expectations

Possibly related PRs

Suggested labels

major

Suggested reviewers

  • aknysh
  • osterman
  • mcalhoun

Pre-merge checks and finishing touches

✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'pass config by ref' clearly and concisely describes the main change: converting configuration parameters from values to pointers throughout the codebase.

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.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
errors/error_funcs_test.go (1)

259-264: Need pointer when calling InitializeMarkdown

InitializeMarkdown now accepts *schema.AtmosConfiguration; passing a value here stops the test from compiling. Quick fix: pass &atmosConfig so the build stays green.

-		InitializeMarkdown(atmosConfig)
+		InitializeMarkdown(&atmosConfig)
pkg/ui/markdown/renderer.go (1)

247-266: Guard against nil atmosConfig before dereferencing

This helper now receives a pointer and touches atmosConfig.Settings right away. If any caller passes nil, we’ll panic before we even reach NewRenderer. Add the same defensive check here so both constructor paths reject nil inputs gracefully.

 func NewTerminalMarkdownRenderer(atmosConfig *schema.AtmosConfiguration) (*Renderer, error) {
+	if atmosConfig == nil {
+		return nil, fmt.Errorf("markdown.NewTerminalMarkdownRenderer: atmos config is nil")
+	}
 	maxWidth := atmosConfig.Settings.Docs.MaxWidth
🧹 Nitpick comments (1)
errors/error_funcs.go (1)

24-27: Shift InitializeMarkdown to pointer input

Thanks for pushing the pointer sweep. Passing schema.AtmosConfiguration by value here still clones the whole struct before you take its address, so we keep the allocation you’re trying to retire. Please update the signature to accept *schema.AtmosConfiguration and thread the pointer through the existing callers to finish the pass-by-ref change.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between f21e0b4 and d303294.

📒 Files selected for processing (13)
  • cmd/root.go (1 hunks)
  • errors/error_funcs.go (1 hunks)
  • errors/error_funcs_test.go (2 hunks)
  • internal/tui/templates/help_printer.go (1 hunks)
  • internal/tui/templates/templater.go (2 hunks)
  • internal/tui/utils/utils.go (1 hunks)
  • pkg/telemetry/utils_test.go (4 hunks)
  • pkg/ui/markdown/markdown_test.go (10 hunks)
  • pkg/ui/markdown/renderer.go (3 hunks)
  • pkg/ui/markdown/renderer_test.go (2 hunks)
  • pkg/ui/markdown/styles.go (1 hunks)
  • pkg/utils/markdown_utils.go (1 hunks)
  • pkg/utils/markdown_utils_test.go (6 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
pkg/**/*.go

📄 CodeRabbit inference engine (.cursor/rules/atmos-rules.mdc)

Place business logic in pkg rather than in cmd

Files:

  • pkg/utils/markdown_utils.go
  • pkg/ui/markdown/styles.go
  • pkg/ui/markdown/renderer_test.go
  • pkg/ui/markdown/renderer.go
  • pkg/telemetry/utils_test.go
  • pkg/ui/markdown/markdown_test.go
  • pkg/utils/markdown_utils_test.go
**/*.go

📄 CodeRabbit inference engine (.cursor/rules/atmos-rules.mdc)

**/*.go: All code must pass golangci-lint checks
Follow Go error handling idioms and use meaningful error messages
Wrap errors with context using fmt.Errorf("context: %w", err)
Consider custom error types for domain-specific errors
Follow standard Go coding style; run gofmt and goimports
Use snake_case for environment variables
Document complex logic with inline comments

Files:

  • pkg/utils/markdown_utils.go
  • pkg/ui/markdown/styles.go
  • errors/error_funcs_test.go
  • pkg/ui/markdown/renderer_test.go
  • pkg/ui/markdown/renderer.go
  • internal/tui/utils/utils.go
  • pkg/telemetry/utils_test.go
  • internal/tui/templates/templater.go
  • internal/tui/templates/help_printer.go
  • errors/error_funcs.go
  • cmd/root.go
  • pkg/ui/markdown/markdown_test.go
  • pkg/utils/markdown_utils_test.go
**/!(*_test).go

📄 CodeRabbit inference engine (.cursor/rules/atmos-rules.mdc)

Document all exported functions, types, and methods with Go doc comments

Files:

  • pkg/utils/markdown_utils.go
  • pkg/ui/markdown/styles.go
  • pkg/ui/markdown/renderer.go
  • internal/tui/utils/utils.go
  • internal/tui/templates/templater.go
  • internal/tui/templates/help_printer.go
  • errors/error_funcs.go
  • cmd/root.go
**/*_test.go

📄 CodeRabbit inference engine (.cursor/rules/atmos-rules.mdc)

**/*_test.go: Every new feature must include comprehensive unit tests
Test both happy paths and error conditions
Use table-driven tests for multiple scenarios

Files:

  • errors/error_funcs_test.go
  • pkg/ui/markdown/renderer_test.go
  • pkg/telemetry/utils_test.go
  • pkg/ui/markdown/markdown_test.go
  • pkg/utils/markdown_utils_test.go
cmd/**/*.go

📄 CodeRabbit inference engine (.cursor/rules/atmos-rules.mdc)

cmd/**/*.go: Use Cobra's recommended command structure with a root command and subcommands
Implement each CLI command in a separate file under cmd/
Use Viper for managing configuration, environment variables, and flags in the CLI
Keep separation of concerns between CLI interface (cmd) and business logic
Use kebab-case for command-line flags
Provide comprehensive help text for all commands and flags
Include examples in Cobra command help
Use Viper for configuration management; support files, env vars, and flags with precedence flags > env > config > defaults
Follow single responsibility; separate command interface from business logic
Provide meaningful user feedback and include progress indicators for long-running operations
Provide clear error messages to users and troubleshooting hints where appropriate

Files:

  • cmd/root.go
🧠 Learnings (25)
📓 Common learnings
Learnt from: Listener430
Repo: cloudposse/atmos PR: 934
File: tests/fixtures/scenarios/docs-generate/README.md.gotmpl:99-118
Timestamp: 2025-01-25T03:51:57.689Z
Learning: For the cloudposse/atmos repository, changes to template contents should be handled in dedicated PRs and are typically considered out of scope for PRs focused on other objectives.
Learnt from: samtholiya
Repo: cloudposse/atmos PR: 1466
File: toolchain/http_client_test.go:3-10
Timestamp: 2025-09-10T21:17:55.273Z
Learning: In the cloudposse/atmos repository, imports should never be changed as per samtholiya's coding guidelines.
Learnt from: aknysh
Repo: cloudposse/atmos PR: 944
File: go.mod:206-206
Timestamp: 2025-01-17T00:18:57.769Z
Learning: For indirect dependencies with license compliance issues in the cloudposse/atmos repository, the team prefers to handle them in follow-up PRs rather than blocking the current changes, as these issues often require deeper investigation of the dependency tree.
Learnt from: osterman
Repo: cloudposse/atmos PR: 808
File: pkg/config/config.go:478-483
Timestamp: 2024-12-02T21:26:32.337Z
Learning: In the 'atmos' project, when reviewing Go code like `pkg/config/config.go`, avoid suggesting file size checks after downloading remote configs if such checks aren't implemented elsewhere in the codebase.
Learnt from: aknysh
Repo: cloudposse/atmos PR: 943
File: internal/exec/describe_config.go:37-37
Timestamp: 2025-01-19T23:13:50.429Z
Learning: When reviewing pointer usage with `EvaluateYqExpression`, check if the `atmosConfig` parameter is already a pointer (e.g., when returned by `InitCliConfig`) to avoid suggesting unnecessary address-of operations.
Learnt from: milldr
Repo: cloudposse/atmos PR: 1229
File: internal/exec/workflow_test.go:0-0
Timestamp: 2025-06-02T14:12:02.710Z
Learning: In the atmos codebase, workflow error handling was refactored to use `PrintErrorMarkdown` followed by returning the error instead of `PrintErrorMarkdownAndExit`. This pattern allows proper error testing without the function terminating the process with `os.Exit`, enabling unit tests to assert on error conditions.
📚 Learning: 2025-08-16T23:32:40.412Z
Learnt from: aknysh
Repo: cloudposse/atmos PR: 1405
File: internal/exec/describe_dependents_test.go:455-456
Timestamp: 2025-08-16T23:32:40.412Z
Learning: In the cloudposse/atmos Go codebase, `InitCliConfig` returns a `schema.AtmosConfiguration` value (not a pointer), while `ExecuteDescribeDependents` expects a `*schema.AtmosConfiguration` pointer parameter. Therefore, when passing the result of `InitCliConfig` to `ExecuteDescribeDependents`, use `&atmosConfig` to pass the address of the value.

Applied to files:

  • pkg/utils/markdown_utils.go
  • pkg/ui/markdown/styles.go
  • errors/error_funcs_test.go
  • pkg/ui/markdown/renderer_test.go
  • pkg/ui/markdown/renderer.go
  • internal/tui/utils/utils.go
  • pkg/telemetry/utils_test.go
  • internal/tui/templates/templater.go
  • internal/tui/templates/help_printer.go
  • errors/error_funcs.go
  • cmd/root.go
  • pkg/ui/markdown/markdown_test.go
  • pkg/utils/markdown_utils_test.go
📚 Learning: 2025-08-16T23:33:07.477Z
Learnt from: aknysh
Repo: cloudposse/atmos PR: 1405
File: internal/exec/describe_dependents_test.go:651-652
Timestamp: 2025-08-16T23:33:07.477Z
Learning: In the cloudposse/atmos Go codebase, ExecuteDescribeDependents expects a pointer to AtmosConfiguration (*schema.AtmosConfiguration), so when calling it with a value returned by cfg.InitCliConfig (which returns schema.AtmosConfiguration), the address-of operator (&) is necessary: ExecuteDescribeDependents(&atmosConfig, ...).

Applied to files:

  • pkg/utils/markdown_utils.go
  • errors/error_funcs_test.go
  • pkg/ui/markdown/renderer_test.go
  • pkg/ui/markdown/renderer.go
  • internal/tui/utils/utils.go
  • pkg/telemetry/utils_test.go
  • internal/tui/templates/templater.go
  • internal/tui/templates/help_printer.go
  • cmd/root.go
  • pkg/ui/markdown/markdown_test.go
  • pkg/utils/markdown_utils_test.go
📚 Learning: 2025-06-02T14:12:02.710Z
Learnt from: milldr
Repo: cloudposse/atmos PR: 1229
File: internal/exec/workflow_test.go:0-0
Timestamp: 2025-06-02T14:12:02.710Z
Learning: In the atmos codebase, workflow error handling was refactored to use `PrintErrorMarkdown` followed by returning the error instead of `PrintErrorMarkdownAndExit`. This pattern allows proper error testing without the function terminating the process with `os.Exit`, enabling unit tests to assert on error conditions.

Applied to files:

  • pkg/utils/markdown_utils.go
  • errors/error_funcs_test.go
  • pkg/telemetry/utils_test.go
  • internal/tui/templates/templater.go
  • internal/tui/templates/help_printer.go
  • errors/error_funcs.go
  • cmd/root.go
  • pkg/ui/markdown/markdown_test.go
  • pkg/utils/markdown_utils_test.go
📚 Learning: 2024-10-23T21:36:40.262Z
Learnt from: osterman
Repo: cloudposse/atmos PR: 740
File: cmd/cmd_utils.go:340-359
Timestamp: 2024-10-23T21:36:40.262Z
Learning: In the Go codebase for Atmos, when reviewing functions like `checkAtmosConfig` in `cmd/cmd_utils.go`, avoid suggesting refactoring to return errors instead of calling `os.Exit` if such changes would significantly increase the scope due to the need to update multiple call sites.

Applied to files:

  • pkg/ui/markdown/styles.go
  • errors/error_funcs_test.go
  • pkg/ui/markdown/renderer.go
  • internal/tui/utils/utils.go
  • pkg/telemetry/utils_test.go
  • internal/tui/templates/templater.go
  • internal/tui/templates/help_printer.go
  • errors/error_funcs.go
  • cmd/root.go
  • pkg/ui/markdown/markdown_test.go
  • pkg/utils/markdown_utils_test.go
📚 Learning: 2024-12-02T21:26:32.337Z
Learnt from: osterman
Repo: cloudposse/atmos PR: 808
File: pkg/config/config.go:478-483
Timestamp: 2024-12-02T21:26:32.337Z
Learning: In the 'atmos' project, when reviewing Go code like `pkg/config/config.go`, avoid suggesting file size checks after downloading remote configs if such checks aren't implemented elsewhere in the codebase.

Applied to files:

  • pkg/ui/markdown/styles.go
  • errors/error_funcs_test.go
  • cmd/root.go
  • pkg/ui/markdown/markdown_test.go
  • pkg/utils/markdown_utils_test.go
📚 Learning: 2025-06-02T14:12:02.710Z
Learnt from: milldr
Repo: cloudposse/atmos PR: 1229
File: internal/exec/workflow_test.go:0-0
Timestamp: 2025-06-02T14:12:02.710Z
Learning: In the atmos codebase, workflow error handling was refactored to use `PrintErrorMarkdown` followed by returning specific error variables (like `ErrWorkflowNoSteps`, `ErrInvalidFromStep`, `ErrInvalidWorkflowStepType`, `ErrWorkflowStepFailed`) instead of `PrintErrorMarkdownAndExit`. This pattern allows proper error testing without the function terminating the process with `os.Exit`, enabling unit tests to assert on error conditions while maintaining excellent user-facing error formatting.

Applied to files:

  • errors/error_funcs_test.go
  • pkg/telemetry/utils_test.go
  • errors/error_funcs.go
  • pkg/ui/markdown/markdown_test.go
  • pkg/utils/markdown_utils_test.go
📚 Learning: 2024-12-12T15:17:45.245Z
Learnt from: osterman
Repo: cloudposse/atmos PR: 808
File: examples/demo-atmos.d/atmos.d/tools/helmfile.yml:10-10
Timestamp: 2024-12-12T15:17:45.245Z
Learning: In `examples/demo-atmos.d/atmos.d/tools/helmfile.yml`, when suggesting changes to `kubeconfig_path`, ensure that the values use valid Go template syntax.

Applied to files:

  • errors/error_funcs_test.go
  • internal/tui/templates/templater.go
  • internal/tui/templates/help_printer.go
📚 Learning: 2025-09-13T18:06:07.674Z
Learnt from: samtholiya
Repo: cloudposse/atmos PR: 1466
File: toolchain/list.go:39-42
Timestamp: 2025-09-13T18:06:07.674Z
Learning: In the cloudposse/atmos repository, for UI messages in the toolchain package, use utils.PrintfMessageToTUI instead of log.Error or fmt.Fprintln(os.Stderr, ...). Import pkg/utils with alias "u" to follow the established pattern.

Applied to files:

  • errors/error_funcs_test.go
  • cmd/root.go
  • pkg/ui/markdown/markdown_test.go
  • pkg/utils/markdown_utils_test.go
📚 Learning: 2024-12-07T16:16:13.038Z
Learnt from: Listener430
Repo: cloudposse/atmos PR: 825
File: internal/exec/helmfile_generate_varfile.go:28-31
Timestamp: 2024-12-07T16:16:13.038Z
Learning: In `internal/exec/helmfile_generate_varfile.go`, the `--help` command (`./atmos helmfile generate varfile --help`) works correctly without requiring stack configurations, and the only change needed was to make `ProcessCommandLineArgs` exportable by capitalizing its name.

Applied to files:

  • errors/error_funcs_test.go
  • internal/tui/templates/templater.go
  • internal/tui/templates/help_printer.go
  • cmd/root.go
📚 Learning: 2025-02-03T06:00:11.419Z
Learnt from: samtholiya
Repo: cloudposse/atmos PR: 959
File: cmd/describe_config.go:20-20
Timestamp: 2025-02-03T06:00:11.419Z
Learning: Commands should use `PrintErrorMarkdownAndExit` with empty title and suggestion (`"", err, ""`) for general error handling. Specific titles like "Invalid Usage" or "File Not Found" should only be used for validation or specific error scenarios.

Applied to files:

  • errors/error_funcs_test.go
  • internal/tui/templates/templater.go
  • internal/tui/templates/help_printer.go
📚 Learning: 2025-02-03T06:00:11.419Z
Learnt from: samtholiya
Repo: cloudposse/atmos PR: 959
File: cmd/describe_config.go:20-20
Timestamp: 2025-02-03T06:00:11.419Z
Learning: The `describe config` command should use `PrintErrorMarkdownAndExit` with empty title and suggestion for consistency with other commands.

Applied to files:

  • errors/error_funcs_test.go
  • internal/tui/templates/templater.go
📚 Learning: 2025-09-23T02:30:42.362Z
Learnt from: CR
Repo: cloudposse/atmos PR: 0
File: .cursor/rules/atmos-rules.mdc:0-0
Timestamp: 2025-09-23T02:30:42.362Z
Learning: Applies to **/*_test.go : Use table-driven tests for multiple scenarios

Applied to files:

  • pkg/ui/markdown/renderer_test.go
  • pkg/ui/markdown/markdown_test.go
  • pkg/utils/markdown_utils_test.go
📚 Learning: 2025-09-13T16:39:20.007Z
Learnt from: samtholiya
Repo: cloudposse/atmos PR: 1466
File: cmd/markdown/atmos_toolchain_aliases.md:2-4
Timestamp: 2025-09-13T16:39:20.007Z
Learning: In the cloudposse/atmos repository, CLI documentation files in cmd/markdown/ follow a specific format that uses " $ atmos command" (with leading space and dollar sign prompt) in code blocks. This is the established project convention and should not be changed to comply with standard markdownlint rules MD040 and MD014.

Applied to files:

  • internal/tui/templates/templater.go
  • cmd/root.go
  • pkg/utils/markdown_utils_test.go
📚 Learning: 2025-01-07T20:38:09.618Z
Learnt from: samtholiya
Repo: cloudposse/atmos PR: 896
File: cmd/editor_config.go:37-40
Timestamp: 2025-01-07T20:38:09.618Z
Learning: Error handling suggestion for `cmd.Help()` in `cmd/editor_config.go` was deferred as the code is planned for future modifications.

Applied to files:

  • internal/tui/templates/templater.go
📚 Learning: 2025-09-23T02:30:42.362Z
Learnt from: CR
Repo: cloudposse/atmos PR: 0
File: .cursor/rules/atmos-rules.mdc:0-0
Timestamp: 2025-09-23T02:30:42.362Z
Learning: Applies to cmd/**/*.go : Include examples in Cobra command help

Applied to files:

  • internal/tui/templates/templater.go
📚 Learning: 2025-09-23T02:30:42.362Z
Learnt from: CR
Repo: cloudposse/atmos PR: 0
File: .cursor/rules/atmos-rules.mdc:0-0
Timestamp: 2025-09-23T02:30:42.362Z
Learning: Applies to cmd/**/*.go : Provide comprehensive help text for all commands and flags

Applied to files:

  • internal/tui/templates/templater.go
📚 Learning: 2025-01-30T19:30:59.120Z
Learnt from: samtholiya
Repo: cloudposse/atmos PR: 959
File: cmd/workflow.go:74-74
Timestamp: 2025-01-30T19:30:59.120Z
Learning: Error handling for `cmd.Usage()` is not required in the Atmos CLI codebase, as confirmed by the maintainer.

Applied to files:

  • internal/tui/templates/templater.go
📚 Learning: 2024-10-20T13:12:46.499Z
Learnt from: haitham911
Repo: cloudposse/atmos PR: 736
File: pkg/config/const.go:6-6
Timestamp: 2024-10-20T13:12:46.499Z
Learning: In `cmd/cmd_utils.go`, it's acceptable to have hardcoded references to `atmos.yaml` in logs, and it's not necessary to update them to use the `CliConfigFileName` constant.

Applied to files:

  • cmd/root.go
📚 Learning: 2024-12-11T18:40:12.808Z
Learnt from: Listener430
Repo: cloudposse/atmos PR: 844
File: cmd/helmfile.go:37-37
Timestamp: 2024-12-11T18:40:12.808Z
Learning: In the atmos project, `cliConfig` is initialized within the `cmd` package in `root.go` and can be used in other command files.

Applied to files:

  • cmd/root.go
📚 Learning: 2024-12-13T15:28:13.630Z
Learnt from: Listener430
Repo: cloudposse/atmos PR: 844
File: cmd/version.go:34-44
Timestamp: 2024-12-13T15:28:13.630Z
Learning: In `cmd/version.go`, when handling the `--check` flag in the `versionCmd`, avoid using `CheckForAtmosUpdateAndPrintMessage(cliConfig)` as it updates the cache timestamp, which may not be desired in this context.

Applied to files:

  • cmd/root.go
📚 Learning: 2025-02-06T13:38:07.216Z
Learnt from: Listener430
Repo: cloudposse/atmos PR: 984
File: internal/exec/copy_glob.go:0-0
Timestamp: 2025-02-06T13:38:07.216Z
Learning: The `u.LogTrace` function in the `cloudposse/atmos` repository accepts `atmosConfig` as its first parameter, followed by the message string.

Applied to files:

  • cmd/root.go
📚 Learning: 2025-09-23T02:30:42.362Z
Learnt from: CR
Repo: cloudposse/atmos PR: 0
File: .cursor/rules/atmos-rules.mdc:0-0
Timestamp: 2025-09-23T02:30:42.362Z
Learning: Applies to **/*_test.go : Test both happy paths and error conditions

Applied to files:

  • pkg/ui/markdown/markdown_test.go
  • pkg/utils/markdown_utils_test.go
📚 Learning: 2025-08-15T14:43:41.030Z
Learnt from: aknysh
Repo: cloudposse/atmos PR: 1352
File: pkg/store/artifactory_store_test.go:108-113
Timestamp: 2025-08-15T14:43:41.030Z
Learning: In test files for the atmos project, it's acceptable to ignore errors from os.Setenv/Unsetenv operations during test environment setup and teardown, as these are controlled test scenarios.

Applied to files:

  • pkg/ui/markdown/markdown_test.go
📚 Learning: 2025-02-05T20:16:24.036Z
Learnt from: samtholiya
Repo: cloudposse/atmos PR: 959
File: pkg/ui/markdown/renderer.go:75-75
Timestamp: 2025-02-05T20:16:24.036Z
Learning: The Purple constant for markdown rendering is defined in pkg/ui/markdown/colors.go.

Applied to files:

  • pkg/utils/markdown_utils_test.go
🧬 Code graph analysis (13)
pkg/utils/markdown_utils.go (3)
errors/error_funcs.go (1)
  • InitializeMarkdown (24-30)
pkg/schema/schema.go (1)
  • AtmosConfiguration (27-65)
pkg/perf/perf.go (1)
  • Track (121-138)
pkg/ui/markdown/styles.go (1)
pkg/schema/schema.go (1)
  • AtmosConfiguration (27-65)
errors/error_funcs_test.go (2)
pkg/ui/markdown/renderer.go (1)
  • NewTerminalMarkdownRenderer (247-267)
pkg/schema/schema.go (1)
  • AtmosConfiguration (27-65)
pkg/ui/markdown/renderer_test.go (2)
pkg/ui/markdown/renderer.go (1)
  • NewRenderer (29-78)
pkg/schema/schema.go (1)
  • AtmosConfiguration (27-65)
pkg/ui/markdown/renderer.go (2)
pkg/schema/schema.go (1)
  • AtmosConfiguration (27-65)
pkg/ui/markdown/styles.go (1)
  • GetDefaultStyle (24-90)
internal/tui/utils/utils.go (2)
pkg/ui/markdown/styles.go (1)
  • GetDefaultStyle (24-90)
pkg/schema/schema.go (1)
  • AtmosConfiguration (27-65)
pkg/telemetry/utils_test.go (2)
pkg/utils/markdown_utils.go (1)
  • InitializeMarkdown (96-104)
pkg/schema/schema.go (1)
  • AtmosConfiguration (27-65)
internal/tui/templates/templater.go (2)
pkg/ui/markdown/renderer.go (1)
  • NewTerminalMarkdownRenderer (247-267)
pkg/schema/schema.go (1)
  • AtmosConfiguration (27-65)
internal/tui/templates/help_printer.go (2)
pkg/ui/markdown/renderer.go (1)
  • NewTerminalMarkdownRenderer (247-267)
pkg/schema/schema.go (1)
  • AtmosConfiguration (27-65)
errors/error_funcs.go (1)
pkg/ui/markdown/renderer.go (1)
  • NewTerminalMarkdownRenderer (247-267)
cmd/root.go (2)
errors/error_funcs.go (1)
  • InitializeMarkdown (24-30)
pkg/utils/markdown_utils.go (1)
  • InitializeMarkdown (96-104)
pkg/ui/markdown/markdown_test.go (3)
pkg/ui/markdown/renderer.go (2)
  • NewRenderer (29-78)
  • NewTerminalMarkdownRenderer (247-267)
pkg/schema/schema.go (1)
  • AtmosConfiguration (27-65)
pkg/ui/markdown/styles.go (1)
  • GetDefaultStyle (24-90)
pkg/utils/markdown_utils_test.go (4)
pkg/ui/markdown/renderer.go (1)
  • NewTerminalMarkdownRenderer (247-267)
pkg/schema/schema.go (1)
  • AtmosConfiguration (27-65)
errors/error_funcs.go (1)
  • InitializeMarkdown (24-30)
pkg/utils/markdown_utils.go (1)
  • InitializeMarkdown (96-104)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Summary

Comment on lines +29 to 36
func NewRenderer(atmosConfig *schema.AtmosConfiguration, opts ...Option) (*Renderer, error) {
r := &Renderer{
width: defaultWidth, // default width
profile: termenv.ColorProfile(), // default color profile
isTTYSupportForStdout: term.IsTTYSupportForStdout,
isTTYSupportForStderr: term.IsTTYSupportForStderr,
atmosConfig: &atmosConfig,
atmosConfig: atmosConfig,
}
Copy link
Contributor

@coderabbitai coderabbitai bot Nov 5, 2025

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Prevent nil atmosConfig panics in constructor

Switching this parameter to a pointer means callers can now pass nil. We dereference atmosConfig immediately, so a nil value will panic—something that couldn’t happen when the argument was passed by value. Please short-circuit with a descriptive error before the first dereference. This keeps the new API shape safe and makes the regression testable.

 func NewRenderer(atmosConfig *schema.AtmosConfiguration, opts ...Option) (*Renderer, error) {
+	if atmosConfig == nil {
+		return nil, fmt.Errorf("markdown.NewRenderer: atmos config is nil")
+	}
 	r := &Renderer{
 		width:                 defaultWidth,           // default width
 		profile:               termenv.ColorProfile(), // default color profile
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
func NewRenderer(atmosConfig *schema.AtmosConfiguration, opts ...Option) (*Renderer, error) {
r := &Renderer{
width: defaultWidth, // default width
profile: termenv.ColorProfile(), // default color profile
isTTYSupportForStdout: term.IsTTYSupportForStdout,
isTTYSupportForStderr: term.IsTTYSupportForStderr,
atmosConfig: &atmosConfig,
atmosConfig: atmosConfig,
}
func NewRenderer(atmosConfig *schema.AtmosConfiguration, opts ...Option) (*Renderer, error) {
if atmosConfig == nil {
return nil, fmt.Errorf("markdown.NewRenderer: atmos config is nil")
}
r := &Renderer{
width: defaultWidth, // default width
profile: termenv.ColorProfile(), // default color profile
isTTYSupportForStdout: term.IsTTYSupportForStdout,
isTTYSupportForStderr: term.IsTTYSupportForStderr,
atmosConfig: atmosConfig,
}
🤖 Prompt for AI Agents
In pkg/ui/markdown/renderer.go around lines 29 to 36, the NewRenderer
constructor now accepts a pointer but immediately dereferences atmosConfig which
will panic if callers pass nil; add an early nil check at the top of NewRenderer
that returns a descriptive error (e.g., return nil, fmt.Errorf("atmosConfig is
required") or errors.New("...")) before any dereference, so the function
short-circuits safely and the regression can be tested.

Copy link
Member

Choose a reason for hiding this comment

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

@samtholiya please address this ☝️

Copy link
Contributor

Choose a reason for hiding this comment

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

Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!

@mergify
Copy link

mergify bot commented Nov 11, 2025

💥 This pull request now has conflicts. Could you fix it @samtholiya? 🙏

@mergify mergify bot added the conflict This PR has conflicts label Nov 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

conflict This PR has conflicts patch A minor, backward compatible change size/s Small size PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants