Repository navigation
fix(list): prevent nil pointer panic when spinner exits early - #2591
Conversation
|
Tip Atmos Pro
No affected stacks workflow was detected for this pull request. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughSynchronizes spinner background goroutines with Bubble Tea program completion, adds sentinel errors for interrupted spinner and nil results, centralizes spinner post-run evaluation into helpers, and defends ChangesSpinner synchronization and nil-result handling
Sequence Diagram(s)sequenceDiagram
participant Caller
participant ExecWithSpinner
participant Background as BackgroundOperation
participant BubbleTea as p.Run()
participant Evaluator as evaluateSpinnerResult
Caller->>ExecWithSpinner: call ExecWithSpinner(fn)
ExecWithSpinner->>Background: spawn background goroutine
Background->>ExecWithSpinner: send completion message / close goroutineDone
ExecWithSpinner->>BubbleTea: p.Run() (blocks)
BubbleTea->>ExecWithSpinner: return (on interrupt/completion)
ExecWithSpinner->>ExecWithSpinner: wait for <-goroutineDone
ExecWithSpinner->>Evaluator: evaluateSpinnerResult(finalModel, spinnerErr)
Evaluator->>ExecWithSpinner: return result or sentinel error
ExecWithSpinner->>Caller: return final result/error
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@pkg/ui/spinner/spinner.go`:
- Around line 71-78: The spinner error handling currently returns a plain
wrapped error and nil for unexpected model types; replace these with static
sentinel errors from errors/errors.go so callers can use errors.Is.
Specifically, where spinnerErr is checked (e.g., the block returning
fmt.Errorf("spinner error: %w", spinnerErr)), return a wrapped sentinel like
fmt.Errorf("%w: %v", errors.ErrSpinnerRunFailed, spinnerErr) (or create
ErrSpinnerRunFailed in errors/errors.go if missing). For the finalModel type
check (finalModel.(spinnerModel) failing), return a sentinel such as
errors.ErrUnexpectedSpinnerModel (wrap if you want context) instead of nil.
Apply the same change to the other occurrence handling (the second path
referenced) so both spinner-run failures and unexpected model types use static
errors.
🪄 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: 3901180f-ca30-4b4f-8184-0242496da710
📒 Files selected for processing (4)
errors/errors.gopkg/list/list_affected.gopkg/ui/spinner/spinner.gopkg/ui/spinner/spinner_test.go
Codecov Report❌ Patch coverage is
❌ Your patch check has failed because the patch coverage (64.70%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #2591 +/- ##
==========================================
+ Coverage 78.91% 78.92% +0.01%
==========================================
Files 1207 1207
Lines 116438 116464 +26
==========================================
+ Hits 91882 91921 +39
+ Misses 19486 19471 -15
- Partials 5070 5072 +2
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
Andriy Knysh (aknysh)
left a comment
There was a problem hiding this comment.
thanks Miguel Zablah (@MrZablah)
3c1aba3
into
cloudposse:main
|
Tip Atmos Pro
No affected stacks workflow was detected for this pull request. |
|
These changes were released in v1.221.0. |
…atmos into 1198-pact-consumer-contracts * '1198-pact-consumer-contracts' of github.com:cloudposse/atmos: fix(ansible): forward `-- <args>` passthrough to ansible-playbook (#2594) fix(ci): use localhost endpoints in LocalStack demo to avoid DNS hangs (#2598) DAG follow-up: aggregate CI output for concurrent Terraform runs (#2577) fix(list): prevent nil pointer panic when spinner exits early (#2591) feat: describe affected evaluates all provisioned component sections (#2573)
what
atmos list affectedpanicking with a nil pointer dereference (result.Affected) when the spinner program exits before the background operation reports completion.ExecWithSpinner/ExecWithSpinnerDynamicnow wait for the operation goroutine to finish (<-goroutineDone) before returning.evaluateSpinnerResult/evaluateDynamicSpinnerResulthelpers distinguish three outcomes: a spinner-level error, the operation's own error, or an interrupted/never-completed run (newErrSpinnerOperationInterrupted).ExecuteListAffectedCmdnow defensively checks for anilresult and returns a wrappedErrNilResultinstead of dereferencing it.TestEvaluateSpinnerResults) covering both spinner result evaluators across all outcome combinations.why
atmos list affectedcould crash withruntime error: invalid memory address or nil pointer dereferenceatpkg/list/list_affected.go:141. This happened when the bubbletea spinner'sp.Run()returned before the background goroutine running
getAffectedComponentsfinished — e.g. when many concurrent stderr writes (such as repeated ECR login messages, see fix(auth): deduplicate ECR, ECR Public, and EKS integrations to once per process #2564) corrupted the spinner'srender loop, or when the user pressed ctrl+c.
finalModel.err != niland otherwise returnednil, so the caller proceeded with anilresult and panicked.list affected(and any other caller ofExecWithSpinnerDynamic) a clear error instead of acrash.
references
Summary by CodeRabbit
Bug Fixes
Tests