Skip to content

feat(config): resolve variable substitution in extends paths#256

Merged
skevetter merged 4 commits into
mainfrom
6393-2e59-ws-a-varsub-extends
May 11, 2026
Merged

feat(config): resolve variable substitution in extends paths#256
skevetter merged 4 commits into
mainfrom
6393-2e59-ws-a-varsub-extends

Conversation

@skevetter

@skevetter skevetter commented May 7, 2026

Copy link
Copy Markdown
Contributor

Summary

Applies local-scope variable substitution (${localEnv:VAR}, ${localWorkspaceFolder}, ${localWorkspaceFolderBasename}) to extends ref strings before resolving them. Previously, variables in extends paths were used literally because extends resolution ran before the general variable substitution pass.

The fix adds a restricted replacer (extendsVarReplacer) that handles only process-local variables — container-scoped variables are left as literals since the container doesn't exist at extends-resolution time.

Spec Compliance

  • Variables in devcontainer.jsonlocalEnv, localWorkspaceFolder, localWorkspaceFolderBasename are available during configuration resolution
  • Container-scoped variables (containerEnv, containerWorkspaceFolder) correctly excluded since the container doesn't exist at extends-resolution time
  • Default value syntax (${localEnv:VAR:default}) supported per spec

devcontainer-cli Alignment

Aligns with devcontainer-cli reference implementation which applies substitute() before resolving extends.

E2E Test Coverage

  • ${localEnv:VAR} in extends path
  • ${localWorkspaceFolder} in extends path
  • ${localEnv:UNSET:default} fallback
  • Missing env var error case

@netlify

netlify Bot commented May 7, 2026

Copy link
Copy Markdown

Deploy Preview for devsydev canceled.

Name Link
🔨 Latest commit 5c9f55b
🔍 Latest deploy log https://app.netlify.com/projects/devsydev/deploys/6a023c66ea888e00080abcbf

@coderabbitai

coderabbitai Bot commented May 7, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@skevetter has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 59 minutes and 54 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f6c77566-d0e6-43a1-a15f-c86ce415c265

📥 Commits

Reviewing files that changed from the base of the PR and between e06bcf5 and 5c9f55b.

📒 Files selected for processing (11)
  • e2e/tests/extends/extends.go
  • e2e/tests/extends/testdata/varsub-localenv-default/.devcontainer/devcontainer.json
  • e2e/tests/extends/testdata/varsub-localenv-default/.devcontainer/fallback/devcontainer.json
  • e2e/tests/extends/testdata/varsub-localenv-missing/.devcontainer/devcontainer.json
  • e2e/tests/extends/testdata/varsub-localenv/.devcontainer/devcontainer.json
  • e2e/tests/extends/testdata/varsub-localenv/parent/devcontainer.json
  • e2e/tests/extends/testdata/varsub-workspace-folder/.devcontainer/configs/parent/devcontainer.json
  • e2e/tests/extends/testdata/varsub-workspace-folder/.devcontainer/devcontainer.json
  • pkg/devcontainer/config/extends_test.go
  • pkg/devcontainer/config/parse.go
  • pkg/devcontainer/config/substitute.go

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.

skevetter added 3 commits May 11, 2026 15:09
Apply local-scope variable substitution (localEnv, localWorkspaceFolder,
localWorkspaceFolderBasename) to extends ref strings before resolving
them. This enables using environment variables and workspace paths in
devcontainer.json extends references, matching the devcontainer spec's
variable substitution behavior.
Use os.LookupEnv instead of os.Getenv so that an env var set to empty
string is returned as-is, and the default value is only used when the
variable does not exist. Adds test for default value syntax. Also
resolves pre-existing merge conflict in cmd/root.go.
Cover localEnv, localWorkspaceFolder, default-value fallback,
and missing-env-var error scenarios for extends path resolution.
@skevetter
skevetter force-pushed the 6393-2e59-ws-a-varsub-extends branch from c9af992 to e94c1ed Compare May 11, 2026 20:15
…older

Adding extendsVarReplacer introduced two more string literal occurrences
of "localEnv" and "localWorkspaceFolder", crossing the goconst threshold.
Extracted varLocalEnv and varLocalWorkspaceFolder constants shared across
substitute.go and parse.go to satisfy the linter.
@skevetter
skevetter marked this pull request as ready for review May 11, 2026 21:18
@skevetter
skevetter merged commit e73498e into main May 11, 2026
54 checks passed
@skevetter
skevetter deleted the 6393-2e59-ws-a-varsub-extends branch May 11, 2026 21:21
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