Skip to content

Comments

avoid failing compose config on failure to load stack#1878

Merged
jordanstephens merged 2 commits intomainfrom
jordan/avoid-failing-for-session-load-on-compose-config
Jan 29, 2026
Merged

avoid failing compose config on failure to load stack#1878
jordanstephens merged 2 commits intomainfrom
jordan/avoid-failing-for-session-load-on-compose-config

Conversation

@jordanstephens
Copy link
Member

@jordanstephens jordanstephens commented Jan 28, 2026

Description

This PR solves a regression where we are exiting early with an error after failing to load a stack during defang compose config. In this case, we want to only warn about the error, then continue.

Linked Issues

Checklist

  • I have performed a self-review of my code
  • I have added appropriate tests
  • I have updated the Defang CLI docs and/or README to reflect my changes, if necessary

Summary by CodeRabbit

  • Bug Fixes
    • The compose command now handles session load failures more gracefully: it logs a warning and continues execution instead of aborting, allowing subsequent operations (like account info retrieval) to run when possible.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 28, 2026

📝 Walkthrough

Walkthrough

makeComposeConfigCmd in compose.go now logs a warning when session/stack loading fails instead of returning the error, allowing command execution to continue after a failed session initialization.

Changes

Cohort / File(s) Summary
Error handling change
src/cmd/cli/command/compose.go
Replaced returning the session-load error with a warning log (non-fatal), so execution proceeds even if session creation/stack loading fails.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • lionello

Poem

🐇 A soft thump and gentle hop,
Stack failed to load, but we don't stop.
A warning hums, the command goes on,
Moonlit paths keep bouncing on. 🌙

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ 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 directly and clearly describes the main change: preventing 'compose config' from failing when stack loading fails, which aligns with the changeset's modification to log a warning and continue instead of returning an error.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (2.5.0)

level=warning msg="[linters_context] running gomodguard failed: unable to read module file go.mod: current working directory must have a go.mod file: if you are not using go modules it is suggested to disable this linter"
level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain main module or its selected dependencies"


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: 0

Caution

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

⚠️ Outside diff range comments (1)
src/cmd/cli/command/compose.go (1)

546-558: Nil pointer dereference: session will be nil after error from newCommandSessionWithOpts.

The function returns nil when LoadSession fails. The code logs the error at line 550 but continues execution, unconditionally accessing session.Provider (line 553), session.Loader (line 558), and session.Stack (line 582), causing a panic.

Either return after logging the error, check if session is nil before using it, or ensure newCommandSessionWithOpts always returns a usable partial session.

@jordanstephens jordanstephens merged commit d57ebd3 into main Jan 29, 2026
14 checks passed
@jordanstephens jordanstephens deleted the jordan/avoid-failing-for-session-load-on-compose-config branch January 29, 2026 17:39
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.

3 participants