Skip to content

fix(config): make shutdownAction defaults explicit in config resolution#259

Merged
skevetter merged 2 commits into
mainfrom
f9cf-ws-shutdown-defaults
May 11, 2026
Merged

fix(config): make shutdownAction defaults explicit in config resolution#259
skevetter merged 2 commits into
mainfrom
f9cf-ws-shutdown-defaults

Conversation

@skevetter

@skevetter skevetter commented May 7, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds explicit spec-compliant default assignment for shutdownAction in MergeConfiguration: "stopCompose" for Docker Compose-based configs, "stopContainer" for image/Dockerfile-based configs
  • Preserves explicit config-level shutdownAction values that were previously lost when image metadata provided no override
  • Adds unit tests verifying all three cases: image default, compose default, and explicit value preservation
  • Adds e2e tests (via read-configuration --include-merged-configuration) validating defaults and explicit preservation

Spec Reference

Per the devcontainer JSON reference:

shutdownAction: Action to take when the user disconnects from the container in their editor. The default is "stopContainer" for non-Docker Compose configurations and "stopCompose" for Docker Compose configurations.

Valid values: "none", "stopContainer", "stopCompose"

The implementation in merge.go:143-152 matches this spec exactly:

  1. If an explicit shutdownAction is set in the devcontainer config, it is preserved
  2. If no explicit value is set and dockerComposeFile is configured, defaults to "stopCompose"
  3. Otherwise defaults to "stopContainer"

Summary by CodeRabbit

  • New Features

    • Added intelligent default shutdown behavior based on container configuration type. Image-based containers default to stopping the container directly, while Docker Compose configurations default to stopping the entire compose stack. Explicit shutdown action settings are always respected.
  • Tests

    • Added comprehensive unit and end-to-end test coverage for shutdown action configuration defaults and explicit overrides.

Review Change Stack

@netlify

netlify Bot commented May 7, 2026

Copy link
Copy Markdown

Deploy Preview for devsydev canceled.

Name Link
🔨 Latest commit c496f35
🔍 Latest deploy log https://app.netlify.com/projects/devsydev/deploys/6a023b98e00985000843ecbb

@github-actions github-actions Bot added the size/m label May 7, 2026
@coderabbitai

coderabbitai Bot commented May 7, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

Adds post-merge defaulting for ShutdownAction in MergeConfiguration (prefer copied config, else choose compose vs container default) and introduces unit and e2e tests plus testdata fixtures to validate the behavior.

Changes

ShutdownAction Defaulting

Layer / File(s) Summary
ShutdownAction Defaulting Logic
pkg/devcontainer/config/merge.go
Post-merge logic assigns mergedConfig.ShutdownAction: uses copiedConfig.ShutdownAction if set, else ShutdownActionStopCompose when DockerComposeFile exists, otherwise ShutdownActionStopContainer.
Unit Tests / Merge
pkg/devcontainer/config/merge_test.go
Three unit tests verify defaults for image-only (StopContainer), compose-based (StopCompose), and that explicit ShutdownAction values are preserved.
e2e Test
e2e/tests/readconfiguration/readconfiguration.go
Table-driven e2e test runs read-configuration and asserts mergedConfiguration.shutdownAction for image, compose, and explicit-none cases.
e2e Testdata
e2e/tests/readconfiguration/testdata-shutdown-action/..., ...-compose/..., ...-explicit/...
Adds .devcontainer.json fixtures for image-based, compose-based (with docker-compose.yml), and explicit shutdownAction: "none" scenarios plus the compose YAML.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested labels

size/l

🚥 Pre-merge checks | ✅ 4 | ❌ 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 (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: making shutdownAction defaults explicit in config resolution, which aligns with the core purpose of the PR.
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.

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

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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 added the size/l label May 7, 2026
skevetter added 2 commits May 11, 2026 15:10
Apply spec-compliant defaults at the end of MergeConfiguration when
shutdownAction is unset: "stopCompose" for Docker Compose configs,
"stopContainer" for image/Dockerfile configs. Preserves explicit
config values that were being lost when image metadata had no override.
Add read-configuration e2e tests verifying shutdownAction defaults:
- Image-based config defaults to "stopContainer"
- Docker Compose config defaults to "stopCompose"
- Explicit "none" value is preserved unchanged
@skevetter
skevetter marked this pull request as draft May 11, 2026 20:14
@skevetter
skevetter force-pushed the f9cf-ws-shutdown-defaults branch from e247b11 to c496f35 Compare May 11, 2026 20:27
@github-actions github-actions Bot removed the size/l label May 11, 2026
@skevetter
skevetter marked this pull request as ready for review May 11, 2026 21:18
@coderabbitai coderabbitai Bot added the size/l label May 11, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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
`@e2e/tests/readconfiguration/testdata-shutdown-action-compose/.devcontainer.json`:
- Line 3: The devcontainer.json "service" key value is mismatched with the
docker-compose service name; update the "service" entry in .devcontainer.json
from "app" to the exact compose service key "app1" so it matches the service
defined in docker-compose.yml (ensure the "service" property equals "app1" used
by the compose fixture).
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c852e5d3-20e0-442b-906d-9987ada292a0

📥 Commits

Reviewing files that changed from the base of the PR and between e247b11 and c496f35.

📒 Files selected for processing (7)
  • e2e/tests/readconfiguration/readconfiguration.go
  • e2e/tests/readconfiguration/testdata-shutdown-action-compose/.devcontainer.json
  • e2e/tests/readconfiguration/testdata-shutdown-action-compose/docker-compose.yml
  • e2e/tests/readconfiguration/testdata-shutdown-action-explicit/.devcontainer.json
  • e2e/tests/readconfiguration/testdata-shutdown-action/.devcontainer.json
  • pkg/devcontainer/config/merge.go
  • pkg/devcontainer/config/merge_test.go
✅ Files skipped from review due to trivial changes (3)
  • e2e/tests/readconfiguration/testdata-shutdown-action/.devcontainer.json
  • e2e/tests/readconfiguration/testdata-shutdown-action-explicit/.devcontainer.json
  • e2e/tests/readconfiguration/testdata-shutdown-action-compose/docker-compose.yml
🚧 Files skipped from review as they are similar to previous changes (2)
  • pkg/devcontainer/config/merge_test.go
  • pkg/devcontainer/config/merge.go

@@ -0,0 +1,4 @@
{
"dockerComposeFile": "docker-compose.yml",
"service": "app"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Service name must match the compose service key

Line 3 should match the exact service key in docker-compose.yml. Current CI failure (service 'app1' configured in devcontainer.json not found) indicates this fixture set is still mismatched, so the compose-based e2e case won’t run reliably until aligned.

🤖 Prompt for 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.

In
`@e2e/tests/readconfiguration/testdata-shutdown-action-compose/.devcontainer.json`
at line 3, The devcontainer.json "service" key value is mismatched with the
docker-compose service name; update the "service" entry in .devcontainer.json
from "app" to the exact compose service key "app1" so it matches the service
defined in docker-compose.yml (ensure the "service" property equals "app1" used
by the compose fixture).

@skevetter
skevetter merged commit 01b5b82 into main May 11, 2026
54 checks passed
@skevetter
skevetter deleted the f9cf-ws-shutdown-defaults branch May 11, 2026 21:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant