Skip to content

fix: copy Env yaml.Node in GetCommand() for sub-task env inheritance#126

Open
aguynamedryan wants to merge 2 commits into
alajmo:mainfrom
aguynamedryan:fix/env-yaml-node-copy-gh98
Open

fix: copy Env yaml.Node in GetCommand() for sub-task env inheritance#126
aguynamedryan wants to merge 2 commits into
alajmo:mainfrom
aguynamedryan:fix/env-yaml-node-copy-gh98

Conversation

@aguynamedryan

Copy link
Copy Markdown
Contributor

Fixes #98

Problem

When a task invokes another task via commands: - task: <name>, the referenced task's env vars are silently dropped. GetCommand() in core/dao/task.go builds a new Command struct from the referenced task but never copies the Env yaml.Node, so the env section is lost before ParseTaskEnv ever sees it.

Fix

One-line addition in core/dao/task.go inside GetCommand() to copy Env from the referenced task into the new Command, matching how EnvList and the other fields are propagated.

Test

New regression test TestConfig_GetCommand_EnvInheritedByChildTask in core/dao/task_test.go that exercises the task-calls-task path and asserts the child's env vars survive.

Note for maintainer

While tracing this I noticed ConvertTaskToCommand() at core/dao/task.go:473 has the same omission — it also doesn't copy Env. 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.

aguynamedryan and others added 2 commits April 16, 2026 11:46
…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"].
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Envvar defined in task is lost when included as a sub-task

1 participant