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.*.resource context is available within the workflow run)
- From a different workflow or CLI, run the
update method 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/servers and @swamp/hetzner-cloud/load-balancers models
- Would affect any model type where
globalArguments contains 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.*.resource context 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)
Description
When a model's
globalArgumentscontain CEL expressions that reference other models (e.g.,model.test-ssh-key.resource.state.swamp_hetzner_crud_test_key.attributes.id), theupdatemethod fails because it re-evaluates ALLglobalArgumentsfields — including ones irrelevant to the update operation.Steps to Reproduce
globalArguments:model.*.resourcecontext is available within the workflow run)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. Thessh_keysfield is not updatable and should not need to be re-evaluated.Actual Behavior
The update fails with:
The
model.*.resourcecontext 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
@swamp/hetzner-cloud/serversand@swamp/hetzner-cloud/load-balancersmodelsglobalArgumentscontains cross-model CEL expressionsSummary
This bug affects the expression evaluation service when running model methods that use
globalArguments. The root issue is that ALLglobalArgumentsfields are evaluated for every method call, even when only a subset of fields are relevant to the operation. Two potential fix approaches:model.*.resourcecontext persistently available by resolving from the data store rather than requiring an in-memory workflow contextdata.latest()expressions in model definitions (currently rejected by static validation but works at runtime)