Update method fails when globalArguments contain cross-model CEL expressions
Opened by swampadmin · 6/25/2025
Description
When a model's globalArguments contain CEL expressions that reference other models (e.g., model.test-ssh-key.resource.state.swamp_hetzner_crud_test_key.attributes.id), the update method fails because it re-evaluates ALL globalArguments fields — including ones irrelevant to the update operation.
Steps to Reproduce
- Create two models where one references the other via a CEL expression in
globalArguments:
# test-server/definition.yaml
globalArguments:
name: swamp-hetzner-crud-test-srv
labels:
env: test
server_type: cx23
image: ubuntu-24.04
location: fsn1
ssh_keys:
- ${{ string(model.test-ssh-key.resource.state.swamp_hetzner_crud_test_key.attributes.id) }}- Run a workflow that creates both models (this works — the
model.*.resourcecontext is available within the workflow run) - From a different workflow or CLI, run the
updatemethod on the dependent model (e.g., to update labels)
Expected Behavior
The update method should succeed because it only needs to send updatable fields (labels, name) to the API. The ssh_keys field is not updatable and should not need to be re-evaluated.
Actual Behavior
The update fails with:
Invalid expression: No such key: resource
> 1 | string(model["test-ssh-key"].resource.state.swamp_hetzner_crud_test_key.attributes.id)
^The model.*.resource context is only available within the workflow run that created the resource. Running the update from a different workflow or the CLI means that context doesn't exist.
Impact
This affects any model that references another model's data in globalArguments. In our Hetzner Cloud CRUD test suite, this prevents updating servers (references ssh-key) and load-balancers (references network) outside the original create workflow.
Independent models (no cross-model references) update fine.
Environment
- Discovered during Hetzner Cloud CRUD test suite development
- Affects
@swamp/hetzner-cloud/serversand@swamp/hetzner-cloud/load-balancersmodels - Would affect any model type where
globalArgumentscontains cross-model CEL expressions
Summary
This bug affects the expression evaluation service when running model methods that use globalArguments. The root issue is that ALL globalArguments fields are evaluated for every method call, even when only a subset of fields are relevant to the operation. Two potential fix approaches:
- Have the update method only evaluate fields relevant to the update API call (based on the method's schema)
- Make the
model.*.resourcecontext persistently available by resolving from the data store rather than requiring an in-memory workflow context - Allow
data.latest()expressions in model definitions (currently rejected by static validation but works at runtime)
Closed
No activity in this phase yet.
Sign in to post a ripple.