fix: preserve dotenv env on retry#2225
Conversation
Preserve dotenv-derived environment entries when retry paths rebuild a DAG from stored YAML. This keeps retry-from-step command expansion consistent with the original run when working_dir is resolved from base or DAG env. Co-Authored-By: Codex <codex@openai.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (6)
📝 WalkthroughWalkthroughThe PR fixes a bug where environment variables from dotenv files in resolved working directories are lost when retrying a failed DAG step. It introduces deterministic env merging utilities and applies them to both DAG resolution and rebuild paths to preserve loaded entries. ChangesEnvironment variable preservation during DAG restore and reload
Sequence DiagramsequenceDiagram
participant Client as Retry Request
participant Restore as DAG Restore
participant Resolve as ResolveEnv
participant DotEnv as .env<br/>in working_dir
participant Exec as Step Execution
Client->>Restore: restore from previous status
Restore->>DotEnv: load from resolved QUANT_SIGNAL_DIR
DotEnv-->>Restore: PYTHON_BIN, PROJECT_DIR
Restore-->>Restore: merge with loadedEnv
Restore->>Resolve: resolve env for execution
Resolve->>DotEnv: load from resolved working_dir
DotEnv-->>Resolve: PYTHON_BIN, PROJECT_DIR
Resolve-->>Resolve: merge with pre-loaded env
Resolve-->>Restore: complete env
Restore->>Exec: execute step with full env
Exec-->>Client: success (env vars available)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 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 |
|
Actionable comments posted: 0 |
Co-authored-by: Codex <codex@openai.com>
Summary
Preserve dotenv-derived environment variables when retrying a DAG from a failed step.
Changes
working_dirwhen retry code rebuilds the DAG from stored YAMLRelated Issues
Closes #2223
Checklist
Testing
go test ./internal/core/spec -run TestResolveEnvIncludesDotenvFromResolvedWorkingDir -count=1 -vgo test -overlay /private/tmp/dagu-ignore-startall-overlay.json ./internal/cmd -run TestRestoreDAGFromStatusIncludesDotenvFromResolvedWorkingDir -count=1 -vgo test ./internal/cmn/buildenv ./internal/core/spec -count=1go test -overlay /private/tmp/dagu-ignore-startall-overlay.json ./internal/cmd -count=1make testGOCACHE=/private/tmp/dagu-gocache GOLANGCI_LINT_CACHE=/private/tmp/dagu-golangci-cache make checkSummary by cubic
Preserves dotenv-derived env vars when retrying a DAG, so
.envfiles from a resolvedworking_dirremain in effect. Fixes inconsistent command expansion on retry.working_dirwhen retry rebuilds DAG from stored YAML.internal/cmn/buildenv(FromMap,AppendMissing) and apply ininternal/core/spec.ResolveEnvandinternal/cmd.rebuildDAGFromYAML.Written for commit 7daf1ce. Summary will update on new commits.
Review in cubic
Summary by CodeRabbit
.envfiles in DAG working directories are now properly included in resolved runtime environments.