Skip to content

Conversation

@JoshuaLelon
Copy link

Summary

resolveArgsTemplate() only looked up ${VAR} from workflow args (passed via --args-json), so env: { MY_VAR: "${MY_VAR}" } in workflow YAML produced the literal string "${MY_VAR}" instead of the actual value from process.env. This also affected ${VAR} in command, stdin, and cwd fields.

The fix threads the accumulated environment through resolveTemplate, resolveStdin, and resolveCwd so ${VAR} falls back to the process/workflow environment when not found in args. Args still take precedence over env vars.

Also adds relative cwd resolution — cwd: ./scripts now resolves relative to the workflow file's directory instead of being passed as-is to spawn().

lobster-biscuit

Repro Steps

  1. Create a workflow file with env: { TEST_VAR: "${TEST_VAR}" }
  2. Run TEST_VAR=hello lobster run --file workflow.lobster
  3. The step's process.env.TEST_VAR is the literal "${TEST_VAR}" instead of "hello"

Root Cause

resolveArgsTemplate only checked args (workflow-defined args from --args-json). It had no fallback to the environment, so any ${VAR} not defined in args was returned verbatim.

Behavior Changes

  • ${VAR} in env, command, stdin, and cwd values now resolves from the environment when not found in workflow args
  • Precedence: args > env > literal (unchanged match kept as-is)
  • Relative cwd values (e.g. ./scripts) now resolve relative to the workflow file directory
  • No breaking changes to existing behavior — unresolved ${VAR} still pass through as before

Tests

6 new tests in test/workflow_env.test.ts:

Test Result
env var substitution resolves from process.env
workflow-level env overrides parent env
step-level env overrides workflow-level env
args take precedence over env in template substitution
env vars resolve in command templates
relative cwd resolves from workflow file directory

All 53 tests pass (47 existing + 6 new).

pnpm build && pnpm test — clean.

Manual Testing

$ TEST_VAR=hello node bin/lobster.js run --file test/fixtures/env-test.lobster
["hello"]

Sign-Off

  • Models used: Claude Opus 4.6
  • Submitter effort: planned + reviewed
  • Agent notes: ~25 lines of source changes; all optional env params preserve backward compatibility

resolveArgsTemplate() only looked up ${VAR} from workflow args, so
env: { MY_VAR: "${MY_VAR}" } produced the literal string instead of
the actual value. Thread the accumulated env through resolveTemplate,
resolveStdin, and resolveCwd so ${VAR} falls back to the process/
workflow environment when not found in args.

Also resolve relative cwd values against the workflow file directory.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

1 participant