fix: copy Env yaml.Node in GetCommand() for sub-task env inheritance#126
Open
aguynamedryan wants to merge 2 commits into
Open
fix: copy Env yaml.Node in GetCommand() for sub-task env inheritance#126aguynamedryan wants to merge 2 commits into
aguynamedryan wants to merge 2 commits into
Conversation
…lajmogh-98) When a task with env vars was referenced via `commands: - task: task1`, GetCommand() built a Command struct without copying the Env field. This meant ParseTaskEnv() later received an empty yaml.Node and the env vars were silently dropped. Adding `Env: cmd.Env` to the struct literal fixes it. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…lajmogh-98) When a task references another task via `commands: - task: <name>`, the referenced task's env vars must be carried through GetCommand() so that ParseTasksEnv can later evaluate them. This test exercises GetCommand() directly and asserts the Env yaml.Node survives through to ParseNodeEnv. Without the companion fix in 34245ea, the test fails with ParseNodeEnv returning [] instead of ["ABC=def", "FOO=bar"].
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #98
Problem
When a task invokes another task via
commands: - task: <name>, the referenced task'senvvars are silently dropped.GetCommand()incore/dao/task.gobuilds a newCommandstruct from the referenced task but never copies theEnvyaml.Node, so the env section is lost beforeParseTaskEnvever sees it.Fix
One-line addition in
core/dao/task.goinsideGetCommand()to copyEnvfrom the referenced task into the newCommand, matching howEnvListand the other fields are propagated.Test
New regression test
TestConfig_GetCommand_EnvInheritedByChildTaskincore/dao/task_test.gothat exercises the task-calls-task path and asserts the child's env vars survive.Note for maintainer
While tracing this I noticed
ConvertTaskToCommand()atcore/dao/task.go:473has the same omission — it also doesn't copyEnv. That may be a separate latent issue on a different code path. I didn't touch it in this PR to keep the change scoped to #98, but happy to send a follow-up if you'd like that fixed too.