Skip to content

fix: name the offending component/stack in backend_type mismatch errors - #2965

Merged
Andriy Knysh (aknysh) merged 2 commits into
mainfrom
osterman/fix-remote-state-backend-type-default
Aug 20, 2026
Merged

Andriy Knysh (aknysh) merged 2 commits into
mainfrom
osterman/fix-remote-state-backend-type-default

Conversation

@osterman

@osterman Erik Osterman (Cloud Posse) (osterman) commented Aug 20, 2026 •

Copy link
Copy Markdown
Member

what

  • checkTerraformBackendTypeMatch / checkRemoteStateBackendTypeMatch now name the offending component and stack directly in the error's hint text, e.g.:

    component "bootstrap" in stack "sandbox": remote_state_backend_type is "local" but remote_state_backend: only configures s3...

  • Added a Go unit test (TestProcessTerraformRemoteStateBackend_InheritedLocalTypeMismatch) reproducing the exact real-world shape that surfaced this, plus hint-text assertions on the existing mismatch tests.
  • Added a CLI-level fixture/test-case (tests/fixtures/scenarios/remote-state-backend-type-mismatch/, tests/test-cases/remote-state-backend-type-mismatch.yaml) proving the fix end-to-end through the real binary.

why

  • These two checks (added in fix(schemas): accept documented backend types and fields the manifest schema rejected #2953) run during whole-repo stack processing, so a mismatch in one component blocks describe stacks/terraform plan for every other stack too, including ones totally unrelated to the misconfigured component.
  • The component/stack causing the failure were previously attached only via WithContext, which the CLI's default (non --verbose) error renderer drops entirely. The printed error gave zero indication of which of potentially hundreds of components across a repo was actually at fault.
  • Found live in cloudposse/infra-live: atmos describe stacks --stack core-gbl-marketplace failed with only "remote_state_backend_type is local but remote_state_backend: only configures s3" — no component, no stack. It took manually instrumenting the binary with debug prints to discover the real cause was an unrelated plat/sandbox component (vpc-no-provider) that overrides backend_type: local without a matching remote_state_backend_type. With this fix, that same failure now reads:

    component "vpc-no-provider" in stack "orgs/cplive/plat/sandbox/us-east-2": remote_state_backend_type is "local" but remote_state_backend: only configures s3...
    which is immediately actionable.

references

None — found and reported internally, no existing issue.

Summary by CodeRabbit

  • Bug Fixes
    • Improved Terraform backend and remote-state mismatch errors with clearer component and stack context.
    • Enhanced error hints to identify conflicting backend types, including inherited configuration issues.
  • Tests
    • Added regression coverage for backend mismatches across regular and remote-state configurations.
    • Added scenario coverage for mismatches involving unrelated stacks.
    • Improved parallel HTTP redirect test isolation to prevent connection cleanup races.

checkTerraformBackendTypeMatch and checkRemoteStateBackendTypeMatch (added
alongside the manifest-schema fix in #2953) attach component/stack only via
WithContext, which the CLI's default (non---verbose) error renderer drops
entirely. Since these checks run during whole-repo stack processing, a
mismatch anywhere blocks describe stacks/terraform plan for every other
stack too -- with no way to tell which of potentially hundreds of
components is actually at fault.

Thread the stack-file name through terraformBackendConfig and
remoteStateBackendConfig, and put both component and stack directly in the
hint text so they always render, matching a real repro found live in
cloudposse/infra-live: a plat/sandbox component overriding backend_type:
local without a matching remote_state_backend_type broke describe stacks
for a completely unrelated stack, with the printed error giving zero clue
which component was the actual cause.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@atmos-pro

atmos-pro Bot commented Aug 20, 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. Ask AI.

@github-actions

Copy link
Copy Markdown

Dependency Review

✅ No vulnerabilities or license issues found.

Scanned Files

None

@coderabbitai

coderabbitai Bot commented Aug 20, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 1ff5c35c-bf6d-4b10-a172-f08eebea5d86

📥 Commits

Reviewing files that changed from the base of the PR and between 660eb43 and 7503e9c.

📒 Files selected for processing (1)
  • pkg/http/client_test.go

Included review availability: Your plan provides up to 4 included reviews per hour; 2 remain after this review.


📝 Walkthrough

Walkthrough

Terraform backend and remote-state processing now carries stack names into mismatch validation. Errors identify the affected component and stack. Unit tests and an end-to-end fixture cover backend-type conflicts, including inherited S3 remote state with a local backend. The parallel redirect test now uses an isolated HTTP transport.

Changes

Backend mismatch diagnostics

Layer / File(s) Summary
Propagate stack context
internal/exec/stack_processor_backend.go, internal/exec/stack_processor_merge.go
Backend and remote-state configuration structs receive the current stack name.
Enhance mismatch diagnostics
internal/exec/stack_processor_backend.go
Mismatch validation includes stack context. User-facing hints identify the affected component and stack for backend and remote-state conflicts.
Validate mismatch scenarios
internal/exec/stack_processor_backend_test.go, tests/fixtures/scenarios/remote-state-backend-type-mismatch/*, tests/test-cases/remote-state-backend-type-mismatch.yaml
Tests cover regular and remote-state mismatch errors. The scenario covers inherited S3 remote-state configuration conflicting with a component-level local backend.

HTTP test isolation

Layer / File(s) Summary
Isolate redirect test transport
pkg/http/client_test.go
The parallel redirect test uses a dedicated http.Transport through WithTransport.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to 7503e

This change improves mismatch error messages and adds unit and CLI coverage; no actionable merge-blocking risk remains beyond normal checks and review.

Possibly related PRs

  • cloudposse/atmos#2953: Both PRs modify backend type-mismatch validation in internal/exec/stack_processor_backend.go; this PR adds contextual diagnostics.
🚥 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 and concisely summarizes the main change: adding the offending component and stack to backend type mismatch errors.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ 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 osterman/fix-remote-state-backend-type-default

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.

coderabbitai[bot]
coderabbitai Bot previously approved these changes Aug 20, 2026
…ctions race

httptest.Server.Close() unconditionally calls CloseIdleConnections() on the
shared http.DefaultTransport. TestGitHubAuthenticatedTransport_AllRedirectStatusCodes
runs 5 parallel subtests that all wrapped that same default transport, so one
subtest's server teardown could kill another's in-flight connection with
"http: CloseIdleConnections called" (seen in CI shard 2/10). Give each subtest
its own *http.Transport so they no longer share that global state.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@codecov

codecov Bot commented Aug 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.44%. Comparing base (a972f1e) to head (7503e9c).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2965      +/-   ##
==========================================
- Coverage   83.44%   83.44%   -0.01%     
==========================================
  Files        1923     1923              
  Lines      188014   188025      +11     
==========================================
- Hits       156895   156890       -5     
- Misses      23207    23219      +12     
- Partials     7912     7916       +4     
Flag Coverage Δ
unittests 83.44% <100.00%> (-0.01%) ⬇️

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

Files with missing lines Coverage Δ
internal/exec/stack_processor_backend.go 97.72% <100.00%> (+0.03%) ⬆️
internal/exec/stack_processor_merge.go 99.16% <100.00%> (+<0.01%) ⬆️

... and 7 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@aknysh
Andriy Knysh (aknysh) added this pull request to the merge queue Aug 20, 2026
@atmos-pro

atmos-pro Bot commented Aug 20, 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. Ask AI.

@atmos-pro

atmos-pro Bot commented Aug 20, 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. Ask AI.

Merged via the queue into main with commit 705d207 Aug 20, 2026
117 of 118 checks passed
@aknysh
Andriy Knysh (aknysh) deleted the osterman/fix-remote-state-backend-type-default branch August 20, 2026 17:54
@atmos-pro

atmos-pro Bot commented Aug 20, 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. Ask AI.

@github-actions

Copy link
Copy Markdown

These changes were released in v1.226.1.

@github-actions

Copy link
Copy Markdown

These changes were released in v1.227.0-test.9.

@github-actions

Copy link
Copy Markdown

These changes were released in v1.227.0-test.10.

This branch was previously deployed

1 inactive deployment
screengrabs — 7503e9c1 Deployed Aug 20, 2026 by osterman via build #1557
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