Skip to main content
← Back to list
01Issue
BugClosedSwamp Club
AssigneesNone

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

  1. 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) }}
  1. Run a workflow that creates both models (this works — the model.*.resource context is available within the workflow run)
  2. 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:

  1. Have the update method only evaluate fields relevant to the update API call (based on the method's schema)
  2. Make the model.*.resource context persistently available by resolving from the data store rather than requiring an in-memory workflow context
  3. Allow data.latest() expressions in model definitions (currently rejected by static validation but works at runtime)
02Bog Flow
OPENTRIAGEDIN PROGRESSCLOSED

Closed

No activity in this phase yet.

03Sludge Pulse

Sign in to post a ripple.