Skip to content

feat(config): accept ${env.X} in path fields (steps 2-4 of #2615)#2944

Merged
dgageot merged 4 commits into
docker:mainfrom
dgageot:board/92ca9e96ab7b326a
Jun 1, 2026
Merged

feat(config): accept ${env.X} in path fields (steps 2-4 of #2615)#2944
dgageot merged 4 commits into
docker:mainfrom
dgageot:board/92ca9e96ab7b326a

Conversation

@dgageot
Copy link
Copy Markdown
Member

@dgageot dgageot commented Jun 1, 2026

docker-agent has two incompatible environment variable expansion syntaxes: JavaScript template literals (${env.X}) for prompt, header, and command fields, and shell-style ($VAR, ${VAR}, ~) for path fields. Using the wrong syntax in a path field was silently ignored, tracked in #2615.

This PR makes path fields accept both syntaxes. pkg/path.ExpandPath now normalizes the JavaScript form ${env.VAR} to ${VAR} before calling os.ExpandEnv, so toolset working_dir, path fields (memory and tasks path, mcp and lsp working_dir), and related fields accept either syntax. The change is fully backward-compatible — existing $VAR/${VAR}/~ configurations are unchanged.

Only plain ${env.VAR} references are supported in paths; richer expressions like ${env.X || 'default'} are not evaluated (would require importing the goja engine, creating a circular dependency). Resolution uses the OS environment, matching the existing ${X} behavior. The now-obsolete mismatch warnings for working_dir and path fields have been removed from pkg/config/expansion_warnings.go. Warnings remain for truly shell-only fields: toolset env values, ScriptShell working_dir/env, and hook working_dir/env.

This is a partial fix for #2615; a follow-up will address the remaining shell-only fields in step 5. Documentation has been updated with a new variable-expansion matrix and cross-reference comments on the duplicated regex.

Refs #2615

@dgageot dgageot requested a review from a team as a code owner June 1, 2026 11:30
@aheritier aheritier added area/config For configuration parsing, YAML, environment variables kind/feat PR adds a new feature (maps to feat: commit prefix) labels Jun 1, 2026
Copy link
Copy Markdown

@docker-agent docker-agent left a comment

Choose a reason for hiding this comment

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

Assessment: 🟢 APPROVE

The diff was fully reviewed. No bugs or logic errors were found in the changed code.

Summary of changes reviewed:

  • pkg/path/expand.go: New ${env.VAR}${VAR} normalization via regex substitution before os.ExpandEnv. The regex and substitution logic are correct; backward-compatibility with existing $VAR/${VAR}/~ is preserved.
  • pkg/config/expansion_warnings.go: Removal of now-obsolete mismatch warnings for path fields is appropriate given the new dual-syntax support.
  • pkg/path/expand_test.go / pkg/config/expansion_warnings_test.go: Test coverage for the new behaviour and updated warning set looks complete.
  • Documentation updates accurately describe the new dual-syntax support and variable-expansion matrix.

No issues found.

@dgageot dgageot force-pushed the board/92ca9e96ab7b326a branch from d122622 to 27e7e15 Compare June 1, 2026 11:53
@dgageot dgageot merged commit e0f8ca2 into docker:main Jun 1, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/config For configuration parsing, YAML, environment variables kind/feat PR adds a new feature (maps to feat: commit prefix)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants