Skip to content

fix(config): suppress workspace mount when workspaceMount is empty string#287

Merged
skevetter merged 1 commit into
mainfrom
677e-sr-mgr-workspace-mount
May 14, 2026
Merged

fix(config): suppress workspace mount when workspaceMount is empty string#287
skevetter merged 1 commit into
mainfrom
677e-sr-mgr-workspace-mount

Conversation

@skevetter

@skevetter skevetter commented May 14, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Changes WorkspaceMount from string to *string in NonComposeBase config struct to distinguish between omitted (nil → default bind mount) and explicitly empty ("" → suppress mount), per the devcontainer spec
  • Updates getWorkspace() in run.go, substitute() in config.go, config merging in extends.go, mount construction in single.go, and mount collection in result.go to handle the three-way semantics: nil/default, empty/suppress, non-empty/use-as-is
  • Adds nil guard in the Kubernetes driver for the suppressed-mount case
  • Adds TestGetWorkspace_NilWorkspaceMount and updates TestGetWorkspace_EmptyWorkspaceMount to verify suppression behavior

Summary by CodeRabbit

  • Bug Fixes
    • Fixed WorkspaceMount handling to properly distinguish between unset (uses default) and explicitly empty (suppresses mount) configurations, aligning with devcontainer specification behavior.
    • Added validation in Kubernetes driver to prevent pod creation when workspace mount is suppressed.

Review Change Stack

…ring (#283)

Per the devcontainer spec, setting workspaceMount to "" should suppress
the default workspace mount. Previously the string type could not
distinguish between omitted and explicitly empty, so "" fell through
to the default bind mount.

Change WorkspaceMount from string to *string so nil means omitted
(use default mount) and *"" means suppress mount entirely.
@coderabbitai

coderabbitai Bot commented May 14, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

This PR changes WorkspaceMount from a string to a *string field throughout the devcontainer configuration and execution paths, enabling semantic distinction between an unset field (nil) and an explicitly empty string. The change propagates through configuration parsing, merging, substitution, mount resolution, and run options generation, with Kubernetes validation enforcing the requirement for a workspace mount.

Changes

WorkspaceMount Pointer-Based Suppression

Layer / File(s) Summary
Config type change and merging logic
pkg/devcontainer/config/config.go, pkg/devcontainer/config/extends.go, pkg/devcontainer/config_test.go
NonComposeBase.WorkspaceMount is changed from string to *string, and mergeContainerScalars updates its merge condition from checking non-empty string (!= "") to checking non-nil (!= nil). Test setup aligns with the pointer type.
Substitution context and mount collection
pkg/devcontainer/config.go, pkg/devcontainer/config/result.go
runner.substitute updates the substitutionContext.WorkspaceMount assignment to dereference a pointer with a nil check, and GetMounts conditionally appends the workspace mount only when non-empty.
Workspace resolution with pointer semantics
pkg/devcontainer/run.go, pkg/devcontainer/run_test.go
getWorkspace now treats conf.WorkspaceMount as a pointer, explicitly suppressing the mount when it is an empty string and computing default behavior when nil. Tests are updated with a strPtr helper and revised expectations for nil, empty, and custom mount configurations.
Run options generation across Dockerless and regular paths
pkg/devcontainer/single.go
Both getDockerlessRunOptions and getRunOptions apply conditional mount parsing: when substitutionContext.WorkspaceMount is empty, workspaceMountPtr remains nil; otherwise it is parsed and set. The resulting pointer is propagated to the returned driver.RunOptions.
Kubernetes execution validation
pkg/driver/kubernetes/run.go
runContainer adds a guard that checks whether options.WorkspaceMount is nil and returns an explicit error, preventing Kubernetes pod creation when the workspace mount is suppressed.

🎯 2 (Simple) | ⏱️ ~12 minutes

🚥 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: converting WorkspaceMount from string to *string to enable suppression when set to an empty string, aligning with the devcontainer spec behavior.
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.


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.

@netlify

netlify Bot commented May 14, 2026

Copy link
Copy Markdown

Deploy Preview for devsydev ready!

Name Link
🔨 Latest commit 96890c8
🔍 Latest deploy log https://app.netlify.com/projects/devsydev/deploys/6a0604e9fa46190008d5e8cf
😎 Deploy Preview https://deploy-preview-287--devsydev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@skevetter
skevetter marked this pull request as ready for review May 14, 2026 17:41

@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.

Caution

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

⚠️ Outside diff range comments (1)
pkg/devcontainer/config.go (1)

199-204: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Guard against applying consistency to suppressed workspace mount.

When WorkspaceMount is explicitly empty (suppressed), applying consistency creates an invalid mount string like ,consistency='delegated'. The mountSetConsistency function appends consistency to the empty string, producing a malformed result that lacks type/source/target fields.

🛡️ Proposed fix to skip consistency when mount is suppressed
+if options.WorkspaceMountConsistency != "" && substitutionContext.WorkspaceMount != "" {
-if options.WorkspaceMountConsistency != "" {
   substitutionContext.WorkspaceMount = mountSetConsistency(
     substitutionContext.WorkspaceMount,
     options.WorkspaceMountConsistency,
   )
 }
🤖 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 `@pkg/devcontainer/config.go` around lines 199 - 204, The code applies
mountSetConsistency to substitutionContext.WorkspaceMount even when the
workspace mount was explicitly suppressed (empty), producing malformed mounts
like ",consistency='delegated'"; fix by guarding the call so you only call
mountSetConsistency(substitutionContext.WorkspaceMount,
options.WorkspaceMountConsistency) when substitutionContext.WorkspaceMount is
non-empty (and/or non-whitespace) and options.WorkspaceMountConsistency is set,
leaving substitutionContext.WorkspaceMount untouched when it was intentionally
suppressed.
🤖 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.

Outside diff comments:
In `@pkg/devcontainer/config.go`:
- Around line 199-204: The code applies mountSetConsistency to
substitutionContext.WorkspaceMount even when the workspace mount was explicitly
suppressed (empty), producing malformed mounts like ",consistency='delegated'";
fix by guarding the call so you only call
mountSetConsistency(substitutionContext.WorkspaceMount,
options.WorkspaceMountConsistency) when substitutionContext.WorkspaceMount is
non-empty (and/or non-whitespace) and options.WorkspaceMountConsistency is set,
leaving substitutionContext.WorkspaceMount untouched when it was intentionally
suppressed.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 77d1876e-cc8e-4577-8827-3dd1906a136c

📥 Commits

Reviewing files that changed from the base of the PR and between ab8d905 and 96890c8.

📒 Files selected for processing (9)
  • pkg/devcontainer/config.go
  • pkg/devcontainer/config/config.go
  • pkg/devcontainer/config/extends.go
  • pkg/devcontainer/config/result.go
  • pkg/devcontainer/config_test.go
  • pkg/devcontainer/run.go
  • pkg/devcontainer/run_test.go
  • pkg/devcontainer/single.go
  • pkg/driver/kubernetes/run.go

@skevetter
skevetter enabled auto-merge (squash) May 14, 2026 19:19
@skevetter
skevetter merged commit 2992939 into main May 14, 2026
186 of 198 checks passed
@skevetter
skevetter deleted the 677e-sr-mgr-workspace-mount branch May 14, 2026 19:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant