Skip to content

fix(list): gate list instances --upload on settings.pro.enabled - #2330

Merged
Andriy Knysh (aknysh) merged 6 commits into
mainfrom
osterman/no-instances-enabled
Apr 20, 2026
Merged

Andriy Knysh (aknysh) merged 6 commits into
mainfrom
osterman/no-instances-enabled

Conversation

@osterman

@osterman Erik Osterman (Cloud Posse) (osterman) commented Apr 16, 2026 •

Copy link
Copy Markdown
Member

what

  • Change atmos list instances --upload to filter instances by settings.pro.enabled == true (strict boolean) instead of settings.pro.drift_detection.enabled == true.
  • Rename isProDriftDetectionEnabled → isProEnabled and simplify the check to a single lookup on settings.pro.enabled; drift_detection.enabled is no longer consulted.
  • Update all unit, integration, comprehensive, cmd, and benchmark tests to the new fixture shape; add an explicit case proving pro.enabled: true with drift_detection.enabled: false is now enabled.
  • Update website/docs/cli/commands/list/list-instances.mdx to document the filter criterion under --upload, in the examples section, and in the :::tip block (noting it must be a boolean, not the string "true").

why

  • Users with settings.pro.enabled: true configured on their components were hitting No Atmos Pro-enabled instances found; nothing to upload. even when Pro was clearly enabled, because the filter required the narrower drift_detection.enabled sub-key.
  • settings.pro.enabled is the correct top-level enablement flag for Pro; drift detection is one feature among several and shouldn't gate the whole upload.
  • The docs previously described --upload without specifying what made an instance eligible, so the failure mode was invisible to users.

Behavior change (callout)

Components that previously qualified via only settings.pro.drift_detection.enabled: true (without pro.enabled: true) will now be excluded from --upload. Users in that shape must add settings.pro.enabled: true.

references

Summary by CodeRabbit

  • Bug Fixes

    • Pro detection simplified: only an explicit boolean settings.pro.enabled=true marks an instance as Pro; missing/non-boolean values are treated as disabled.
    • Upload behavior: all collected instances are uploaded; post-upload summary shows total uploaded plus enabled/disabled and drift-enabled counts.
    • Improved Pro authentication hints for GitHub Actions and workspace ID.
  • Documentation

    • CLI docs updated to reflect new upload semantics, payload shape, and the "No instances found; nothing to upload." message.
  • Tests

    • Tests updated/added to cover the new Pro flag shape, counting, and upload behavior.

…ection.enabled

Changes the Pro-enabled filter used by `atmos list instances --upload` to
check `settings.pro.enabled == true` (strict boolean) instead of the
narrower `settings.pro.drift_detection.enabled == true`. Updates tests,
benchmarks, and the command reference docs.

Behavior change: components that previously qualified via only
`settings.pro.drift_detection.enabled: true` will now be excluded from
upload unless they also set `settings.pro.enabled: true`.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@atmos-pro

atmos-pro Bot commented Apr 16, 2026 •

Copy link
Copy Markdown
Contributor

Tip

Atmos Pro  

No affected stacks workflow was detected for this pull request.
If this is expected, no action is needed.
Learn More.

View pull request changes on Atmos Pro

@github-actions github-actions Bot added the size/m Medium size PR label Apr 16, 2026
@github-actions

github-actions Bot commented Apr 16, 2026 •

Copy link
Copy Markdown

Dependency Review

✅ No vulnerabilities or license issues found.

Scanned Files

None

@coderabbitai

coderabbitai Bot commented Apr 16, 2026 •

Copy link
Copy Markdown
Contributor

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Changed Pro eligibility to require settings.pro.enabled == true (boolean), removed the Pro-only filter helper, added countEnabledDisabled, upload now sends the full instances slice and reports enabled/disabled/drift counts; tests, benchmarks, docs, and an auth hint were updated accordingly.

Changes

Cohort / File(s) Summary
Core Implementation
pkg/list/list_instances.go
Replaced prior drift-detection predicate with isProEnabled; removed Pro-only filtering helper; added countEnabledDisabled(instances) returning (enabled, disabled, drift); upload now sends full instances slice and TUI success message shows total/uploaded counts and enabled/disabled/drift tallies; adjusted "nothing to upload" condition to len(instances)==0.
Benchmarks
pkg/list/list_instances_bench_test.go
Renamed benchmarks to BenchmarkCountEnabledDisabled and BenchmarkIsProEnabled; updated fixtures to use pro.enabled and to benchmark the new counting/predicate functions.
Tests — command/comprehensive/integration/pro/upload
pkg/list/list_instances_cmd_test.go, pkg/list/list_instances_comprehensive_test.go, pkg/list/list_instances_integration_test.go, pkg/list/list_instances_pro_test.go, pkg/list/list_instances_upload_test.go
Flattened pro fixtures to pro.enabled; removed old filterProEnabledInstances edge-case tests; added TestCountEnabledDisabled and TestUploadInstancesWithDeps_PreservesEnabledDisabled; adjusted upload tests to expect full instance list and preserved settings.pro.enabled values.
Docs
website/docs/cli/commands/list/list-instances.mdx
Updated --upload docs to state uploads include all real instances, settings.pro.enabled must be boolean true to count as enabled and is preserved verbatim in payload; documented post-upload tally (enabled/disabled/drift) and clarified no-instances message.
Auth hint
pkg/pro/commit.go
Refined OIDC/GitHub Actions auth hint: recommend running in Actions with id-token: write and set ATMOS_PRO_WORKSPACE_ID / settings.pro.workspace_id.

Sequence Diagram(s)

sequenceDiagram
    participant CLI as CLI (user)
    participant Processor as Instance Processor
    participant Uploader as Pro Upload Client
    participant TUI as TUI (feedback)

    CLI->>Processor: collect instances
    Processor->>Processor: isProEnabled(instance) / countEnabledDisabled(all)
    Processor->>Uploader: send full instances slice (preserve settings.pro.enabled)
    Uploader->>Processor: upload result (success/failure)
    Processor->>TUI: render success with totals (total, enabled, disabled, drift)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • aknysh
  • milldr
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and accurately reflects the main change: gating list instances --upload on settings.pro.enabled instead of settings.pro.drift_detection.enabled.
Docstring Coverage ✅ Passed Docstring coverage is 86.36% 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
  • Commit unit tests in branch osterman/no-instances-enabled

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.

@coderabbitai coderabbitai Bot left a comment

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.

🧹 Nitpick comments (1)
pkg/list/list_instances_integration_test.go (1)

162-266: Consider table-driving these new Pro edge cases.

The added scenarios are solid, but converting this block to a table-driven test would reduce duplication and make future permutations easier to extend.

As per coding guidelines, "Use table-driven tests for testing multiple scenarios in Go".

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pkg/list/list_instances_integration_test.go` around lines 162 - 266, The test
block adds several independent scenarios for filterProEnabledInstances and
should be refactored into a single table-driven test: create a slice of test
cases (with fields like name string, instances []schema.Instance, wantLen int,
wantFirstComponent string, wantFirstStack string) containing each scenario
(invalid pro structure, drift_detection only, pro.enabled false, pro.enabled
true, etc.), then loop over them with t.Run(tc.name, func(t *testing.T) {
filtered := filterProEnabledInstances(tc.instances); assert.Len/Empty or
assert.Equal checks based on tc.wantLen and optional expected component/stack
fields }); ensure you reuse existing assertions (assert.Empty, assert.Len,
assert.Equal) and keep unique scenario inputs identical to the current
individual test cases.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@pkg/list/list_instances_integration_test.go`:
- Around line 162-266: The test block adds several independent scenarios for
filterProEnabledInstances and should be refactored into a single table-driven
test: create a slice of test cases (with fields like name string, instances
[]schema.Instance, wantLen int, wantFirstComponent string, wantFirstStack
string) containing each scenario (invalid pro structure, drift_detection only,
pro.enabled false, pro.enabled true, etc.), then loop over them with
t.Run(tc.name, func(t *testing.T) { filtered :=
filterProEnabledInstances(tc.instances); assert.Len/Empty or assert.Equal checks
based on tc.wantLen and optional expected component/stack fields }); ensure you
reuse existing assertions (assert.Empty, assert.Len, assert.Equal) and keep
unique scenario inputs identical to the current individual test cases.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 75ed37a4-f061-4a1b-9f66-b39c5d2218fd

📥 Commits

Reviewing files that changed from the base of the PR and between a3fc646 and 0e503ee.

📒 Files selected for processing (7)
  • pkg/list/list_instances.go
  • pkg/list/list_instances_bench_test.go
  • pkg/list/list_instances_cmd_test.go
  • pkg/list/list_instances_comprehensive_test.go
  • pkg/list/list_instances_integration_test.go
  • pkg/list/list_instances_pro_test.go
  • website/docs/cli/commands/list/list-instances.mdx

coderabbitai[bot]
coderabbitai Bot previously approved these changes Apr 16, 2026
@osterman Erik Osterman (Cloud Posse) (osterman) added the patch A minor, backward compatible change label Apr 16, 2026
@codecov

codecov Bot commented Apr 16, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 86.95652% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 77.30%. Comparing base (1d571e9) to head (cad7cea).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
pkg/list/list_instances.go 85.71% 3 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #2330   +/-   ##
=======================================
  Coverage   77.29%   77.30%           
=======================================
  Files        1084     1084           
  Lines      102410   102418    +8     
=======================================
+ Hits        79159    79175   +16     
+ Misses      18889    18881    -8     
  Partials     4362     4362           
Flag Coverage Δ
unittests 77.30% <86.95%> (+<0.01%) ⬆️

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

Files with missing lines Coverage Δ
pkg/pro/commit.go 84.69% <100.00%> (+0.07%) ⬆️
pkg/list/list_instances.go 81.45% <85.71%> (+1.45%) ⬆️

... and 4 files with indirect coverage changes

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

Atmos Pro authentication is OIDC-only — users cannot mint `ATMOS_PRO_TOKEN`
manually. Replace the incorrect hint with guidance matching our docs and the
`describe affected` error path: require `id-token: write` in a GitHub Actions
workflow and set `ATMOS_PRO_WORKSPACE_ID`.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
coderabbitai[bot]
coderabbitai Bot previously approved these changes Apr 16, 2026
…ver-side reconciliation

`atmos list instances --upload` now sends every real (non-abstract) instance
to Atmos Pro, with `settings.pro.enabled` preserved verbatim in the payload.
Previously, instances with `pro.enabled: false` (or no `pro` config) were
filtered out client-side, making "disabled" indistinguishable from "deleted"
on the server. Atmos Pro can now reconcile enabled/disabled state itself —
e.g., grey out disabled instances in the UI instead of losing track of them.

The success toast reports a tally:

    Successfully uploaded 3 instances to Atmos Pro API (1 enabled, 2 disabled).

"No instances found; nothing to upload." only prints for empty repositories.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

@coderabbitai coderabbitai Bot left a comment

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.

🧹 Nitpick comments (1)
pkg/list/list_instances.go (1)

334-335: Consider ui.Success and pluralization for the toast.

Two small, optional tweaks on this changed line:

  1. Per the UI/IO separation guideline, human-facing messages should go through ui.* (stderr) rather than u.PrintfMessageToTUI. ui.Success would signal outcome semantically and keep this consistent with the sibling ui.Info("No instances found; …") a few lines down.
  2. The message renders "1 instances" when len(instances) == 1. A tiny pluralize helper (or conditional) avoids the grammar nit in user output.
♻️ Suggested tweak
-	enabled, disabled := countEnabledDisabled(instances)
-	u.PrintfMessageToTUI("Successfully uploaded %d instances to Atmos Pro API (%d enabled, %d disabled).", len(instances), enabled, disabled)
+	enabled, disabled := countEnabledDisabled(instances)
+	noun := "instances"
+	if len(instances) == 1 {
+		noun = "instance"
+	}
+	ui.Success(fmt.Sprintf("Successfully uploaded %d %s to Atmos Pro API (%d enabled, %d disabled).", len(instances), noun, enabled, disabled))

As per coding guidelines: "Use I/O layer (pkg/io/) for stream access and UI layer (pkg/ui/) for formatting … ui.Write*/Writeln/Success/Error/Warning/Info/Markdown for human messages (stderr)."

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pkg/list/list_instances.go` around lines 334 - 335, Replace the direct TUI
print with the UI layer and fix pluralization: call ui.Success(...) instead of
u.PrintfMessageToTUI(...) and construct the message using len(instances) with a
conditional/plural helper so it says "1 instance" vs "N instances"; keep
enabled/disabled from countEnabledDisabled(instances) and mirror the style used
by ui.Info(...) nearby so all human-facing text flows through pkg/ui.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@pkg/list/list_instances.go`:
- Around line 334-335: Replace the direct TUI print with the UI layer and fix
pluralization: call ui.Success(...) instead of u.PrintfMessageToTUI(...) and
construct the message using len(instances) with a conditional/plural helper so
it says "1 instance" vs "N instances"; keep enabled/disabled from
countEnabledDisabled(instances) and mirror the style used by ui.Info(...) nearby
so all human-facing text flows through pkg/ui.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 136e7290-dda0-4deb-9d80-2d61292ee6c5

📥 Commits

Reviewing files that changed from the base of the PR and between 88fd831 and a3634ab.

📒 Files selected for processing (8)
  • pkg/list/list_instances.go
  • pkg/list/list_instances_bench_test.go
  • pkg/list/list_instances_cmd_test.go
  • pkg/list/list_instances_comprehensive_test.go
  • pkg/list/list_instances_integration_test.go
  • pkg/list/list_instances_pro_test.go
  • pkg/list/list_instances_upload_test.go
  • website/docs/cli/commands/list/list-instances.mdx
✅ Files skipped from review due to trivial changes (1)
  • pkg/list/list_instances_integration_test.go
🚧 Files skipped from review as they are similar to previous changes (4)
  • pkg/list/list_instances_comprehensive_test.go
  • website/docs/cli/commands/list/list-instances.mdx
  • pkg/list/list_instances_bench_test.go
  • pkg/list/list_instances_cmd_test.go

coderabbitai[bot]
coderabbitai Bot previously approved these changes Apr 20, 2026
The success message now reports how many uploaded instances have
drift detection enabled, making it easy to see drift coverage at
a glance after an upload:

    Successfully uploaded 3 instances to Atmos Pro API (1 enabled, 2 disabled, 1 drift enabled).

Drift is counted independently of `pro.enabled`, since
`settings.pro.drift_detection.enabled` can be true even when
`settings.pro.enabled` is false.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 2

🧹 Nitpick comments (1)
pkg/list/list_instances_pro_test.go (1)

13-17: Add a schema field compile guard.

These tests reference schema.Instance.Component, Stack, and Settings; add a package-level sentinel so field renames fail at compile time.

Suggested guard
 import (
 	"testing"
 
 	"github.com/stretchr/testify/assert"
 
 	"github.com/cloudposse/atmos/pkg/schema"
 )
+
+var _ = schema.Instance{
+	Component: "",
+	Stack:     "",
+	Settings:  map[string]any{},
+}

As per coding guidelines, “Add compile-time sentinels for schema field references in tests.”

Also applies to: 21-28, 123-150

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pkg/list/list_instances_pro_test.go` around lines 13 - 17, Add a
package-level compile-time sentinel in pkg/list/list_instances_pro_test.go that
references the specific schema fields used in tests so renames produce compile
errors: create an unused variable that constructs a schema.Instance and accesses
Component and Stack and also references schema.Instance.Settings (or
schema.Settings) to touch Settings; this sentinel should live at top-level of
the test file (outside TestIsProEnabled) and reference the schema.Instance and
schema.Settings symbols so any future field rename will break compilation.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@pkg/list/list_instances.go`:
- Around line 519-525: Filter the instances slice to only include those with
settings.pro.enabled == true before calling uploadInstances: compute a new slice
(e.g., proInstances) by iterating over instances and selecting only items where
instance.Settings.Pro.Enabled (or isProEnabled) is true, replace the
uploadCandidates check and the uploadInstances call to use proInstances, and
keep the existing "No instances found; nothing to upload." message but trigger
it when len(proInstances) == 0 so disabled/no-pro instances are not uploaded.

In `@website/docs/cli/commands/list/list-instances.mdx`:
- Around line 59-60: Update the doc text at the two incorrect spots to state
that the CLI uploads every real instance regardless of settings.pro.enabled,
preserving that flag in the payload so Atmos Pro can manage enabled/disabled
server-side; replace the current claim that only instances with
settings.pro.enabled: true are uploaded (lines referencing `--upload`) with
wording that matches the examples and the Go implementation (see
uploadInstancesWithDeps which does not filter by pro.enabled). Ensure both
occurrences (around the `--upload` dd and the other paragraph at line ~328)
mirror the examples: “All real instances are uploaded; settings.pro.enabled is
included in the payload so the server decides enabled vs. disabled.”

---

Nitpick comments:
In `@pkg/list/list_instances_pro_test.go`:
- Around line 13-17: Add a package-level compile-time sentinel in
pkg/list/list_instances_pro_test.go that references the specific schema fields
used in tests so renames produce compile errors: create an unused variable that
constructs a schema.Instance and accesses Component and Stack and also
references schema.Instance.Settings (or schema.Settings) to touch Settings; this
sentinel should live at top-level of the test file (outside TestIsProEnabled)
and reference the schema.Instance and schema.Settings symbols so any future
field rename will break compilation.
🪄 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 7dcbd540-aa4b-4b4d-a4d3-9d431fd36c2f

📥 Commits

Reviewing files that changed from the base of the PR and between a3634ab and 415a0b0.

📒 Files selected for processing (4)
  • pkg/list/list_instances.go
  • pkg/list/list_instances_bench_test.go
  • pkg/list/list_instances_pro_test.go
  • website/docs/cli/commands/list/list-instances.mdx
🚧 Files skipped from review as they are similar to previous changes (1)
  • pkg/list/list_instances_bench_test.go

Comment thread pkg/list/list_instances.go
Comment thread website/docs/cli/commands/list/list-instances.mdx Outdated
The `--upload` flag summary and the tip at the bottom still said "only
instances with settings.pro.enabled: true are uploaded". That is no longer
true — the CLI uploads every real instance and Atmos Pro reconciles
enabled/disabled state from the preserved `settings.pro.enabled` flag in
the payload. Brought both spots in line with the detailed example section
and the actual implementation.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@aknysh
Andriy Knysh (aknysh) merged commit 66a946e into main Apr 20, 2026
59 checks passed
@atmos-pro

atmos-pro Bot commented Apr 20, 2026

Copy link
Copy Markdown
Contributor

Note

Atmos Pro  

Waiting for your GitHub Actions workflow to upload affected stacks.
Learn More.

@aknysh
Andriy Knysh (aknysh) deleted the osterman/no-instances-enabled branch April 20, 2026 22:28
@github-actions

Copy link
Copy Markdown

These changes were released in v1.216.0-rc.2.

This branch was successfully deployed

1 active deployment
preview — cad7cea1 Deployed Apr 20, 2026 by github-actions[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

patch A minor, backward compatible change size/m Medium size PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants