Relationships
#294 forEach self.* in modelIdOrName not resolved in runtime execution path
Opened by webframp · 5/8/2026· Shipped 5/8/2026
Description
Commit 5a0b2cbc (swamp-club#279, PR #1334) added self.* resolution in modelIdOrName to resolveForEachTaskExpressions() in src/libswamp/workflows/evaluate.ts. This correctly resolves during swamp workflow evaluate display output, but the runtime execution path still passes the raw ${{ self.region }} string to findDefinitionByIdOrName(), causing "Model not found" errors.
Steps to Reproduce
# Workflow with forEach targeting dynamic model names
steps:
- name: summary-${{ self.region }}
forEach:
item: region
in: ${{ inputs.regions }}
task:
type: model_method
modelIdOrName: aws-alarms-${{ self.region }}
methodName: get_summary
inputs:
historyHours: 24
allowFailure: true# Model instances exist
swamp model create @webframp/aws/alarms aws-alarms-us-east-1 --global-arg region=us-east-1
# Run directly — fails
swamp workflow run morning-pulse --input 'regions:json=["us-east-1"]'
# Error: Model not found: aws-alarms-${{ self.region }}
# Evaluate shows correct resolution in display output
swamp workflow evaluate morning-pulse --input 'regions:json=["us-east-1"]' --json | grep modelIdOrName
# "modelIdOrName": "aws-alarms-us-east-1" ← correct
# But evaluated file still has raw expression
grep modelIdOrName .swamp/workflows-evaluated/workflow-*.yaml
# modelIdOrName: 'aws-alarms-${{ self.region }}' ← not persisted
# --last-evaluated also fails (file has unexpanded forEach)
swamp workflow run morning-pulse --last-evaluated
# Error: Model not found: aws-alarms-${{ self.region }}Root Cause
Two gaps remain after swamp-club#279:
Runtime path not patched:
expandForEachSteps()insrc/domain/workflows/execution_service.tscreates theforEachVarcontext and resolves step names, but passes the originalstepobject (with unresolvedmodelIdOrName) to execution. TheresolveForEachTaskExpressions()fix only runs in the evaluate display codepath (src/libswamp/workflows/evaluate.ts), not in the runtime codepath.Evaluated file doesn't persist forEach expansion:
swamp workflow evaluatesaves the workflow YAML with forEach blocks intact andself.*still inmodelIdOrName. The expansion shown in the JSON output is display-only. This means--last-evaluatedcan't work around the runtime gap.
Expected Behavior
swamp workflow run morning-pulse --input 'regions:json=["us-east-1"]' should resolve aws-alarms-${{ self.region }} to aws-alarms-us-east-1 during runtime forEach expansion, matching the behavior shown in swamp workflow evaluate output.
Environment
- swamp version: 20260507.205536.0-sha.10d12371
- OS: Linux
References
- swamp-club#279 / PR #1334 — evaluate-path fix (shipped)
- https://github.com/webframp/swamp-extensions/issues/58 — original discovery context
Shipped
Click a lifecycle step above to view its details.
Sign in to post a ripple.