fix: resolve scheduler no-eval env before subprocess launch#2269
Conversation
|
Need the big picture first? Review this PR in Change Stack to see what changed before going file by file. 📝 WalkthroughWalkthroughThe PR introduces a runtime flag ChangesDAG Environment Evaluation and Reuse Logic
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related issues
Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
internal/core/spec/runtime_env_external_test.go (1)
161-239: ⚡ Quick winAdd a
SourceFile-only regression case for env reload.These tests cover metadata/evaluated/programmatic paths well, but they don’t assert behavior when
Locationis empty and onlySourceFileis set (the provenance path used when runtime location is rewritten).🤖 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 `@internal/core/spec/runtime_env_external_test.go` around lines 161 - 239, Add a regression test that mirrors TestResolveEnvWithWarningsReloadsNoEvalMetadataEnvFromSource but simulates the rewritten-runtime provenance (i.e., clear metadata.Location and keep metadata.SourceFile set) so ResolveEnvWithWarnings still reloads env from the source file; specifically: create the YAML file and load it with spec.Load (or spec.LoadYAML) into metadata, set metadata.Location = "" while leaving metadata.SourceFile populated, call spec.ResolveEnvWithWarnings(ctx, metadata, nil, spec.ResolveEnvOptions{}), and assert that runtimeEnvSliceMap(result.Env)["TOKEN"] == "secret123" and runtimeEnvSliceMap(metadata.Env)["TOKEN"] == "${ISSUE_2268_TOKEN}" to ensure reload happened from SourceFile when Location is empty.
🤖 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.
Inline comments:
In `@internal/core/spec/runtime_env.go`:
- Around line 125-135: The DAG is considered source-backed only via YamlData or
Location but misses core.DAG.SourceFile, causing unnecessary env recomputation;
update hasDAGSource(dag *core.DAG) to also check dag.SourceFile (e.g., return
len(dag.YamlData) > 0 || dag.Location != "" || dag.SourceFile != ""), and ensure
canReuseCurrentEnv and shouldRecomputeEnv naturally pick up that change so raw
no-eval dag.Env can be reused when SourceFile is present and Location was
cleared.
---
Nitpick comments:
In `@internal/core/spec/runtime_env_external_test.go`:
- Around line 161-239: Add a regression test that mirrors
TestResolveEnvWithWarningsReloadsNoEvalMetadataEnvFromSource but simulates the
rewritten-runtime provenance (i.e., clear metadata.Location and keep
metadata.SourceFile set) so ResolveEnvWithWarnings still reloads env from the
source file; specifically: create the YAML file and load it with spec.Load (or
spec.LoadYAML) into metadata, set metadata.Location = "" while leaving
metadata.SourceFile populated, call spec.ResolveEnvWithWarnings(ctx, metadata,
nil, spec.ResolveEnvOptions{}), and assert that
runtimeEnvSliceMap(result.Env)["TOKEN"] == "secret123" and
runtimeEnvSliceMap(metadata.Env)["TOKEN"] == "${ISSUE_2268_TOKEN}" to ensure
reload happened from SourceFile when Location is empty.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 72c52093-d2db-420e-bd92-c06c0ee2dc54
📒 Files selected for processing (4)
internal/core/dag.gointernal/core/spec/dag.gointernal/core/spec/runtime_env.gointernal/core/spec/runtime_env_external_test.go
There was a problem hiding this comment.
1 issue found across 4 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
Summary
Closes #2268
Root cause
Scheduler metadata loads use OnlyMetadata with WithoutEval, leaving env values such as ${MY_SECRET} raw in dag.Env. The subprocess preparation path treated any non-empty dag.Env as already resolved and serialized it as presolved build env, causing child DAG loads to reuse the raw literal instead of expanding the OS environment.
Testing
Summary by cubic
Fix scheduler to resolve no-eval env vars before launching subprocesses and handle source-file-only metadata correctly. Prevents
${VAR}literals from leaking into child DAG loads and recomputes env from source when needed.DAG.EnvEvaluatedto know whenEnvis safe to reuse.PresolvedBuildEnvwhen building withWithoutEval.ResolveEnvWithWarningsto reload fromSourceFile, recompute when params change or raw source-backed metadata exists, and reuse only whenEnvEvaluatedor no source is present.SourceFile.Written for commit dd880c7. Summary will update on new commits.
Summary by CodeRabbit
Release Notes
Performance Improvements
Tests