Compiler ErrorsOperations & Arrays

Operations & Arrays

Errors from the ops: list inside a rule — wrong operation for a field’s type, and array-specific type checks.

21 error codes in this section.

Operation Correctness

VERR_SET_TYPE_MISMATCH

SET value type mismatch. The value in a set op does not match the declared field type.

Impact: Value coercion at runtime may store wrong data or fail silently.

✗ Won't compile
# retry_count is type: integer
ops:
  - op: set
    path: /retry_count
    value: "three"     # string, not integer
✓ Fixed
ops:
  - op: set
    path: /retry_count
    value: 3

VERR_PUSH_TARGET_NOT_ARRAY

PUSH target is not an array. A push op targets a scalar field (string, integer, etc.) instead of an array field.

Impact: Runtime throws; intent fails entirely.

✗ Won't compile
# status is type: string
ops:
  - op: push
    path: /status
    value: active
✓ Fixed
# Declare status as type: array, or use op: set for scalars.

VERR_MERGE_TARGET_NOT_OBJECT

MERGE target is not an object. A merge op targets a non-object field (e.g. an array or scalar).

Impact: Runtime throws; intent fails.

✗ Won't compile
# tags is type: array
ops:
  - op: merge
    path: /tags
    value: { label: "vip" }
✓ Fixed
# Use op: push for arrays, op: merge only for object fields.

VERR_PREFLIGHT_SIDE_EFFECT

Side-effect operation in preflight rule. A preflight rule contains a mutating operation (set, emit, push, etc.). Preflight rules are read-only assertion gates.

Impact: If allowed, side-effects would execute even when the intent is later rejected by a guard.

✗ Won't compile
rules:
  check_inventory:
    mode: preflight
    ops:
      - op: set              # side-effect in preflight
        path: /last_checked_at
        value: "#{ event.ts }"
✓ Fixed
# Preflight rules may only contain if/raise assertions.
# Move mutations to mode: sync or mode: async rules.

VERR_ARITHMETIC_TARGET_NOT_NUMERIC

Arithmetic on non-numeric field. An add or sub op targets a field that is not numeric.

Impact: Runtime throws a type error; intent fails.

✗ Won't compile
# status is type: string
ops:
  - op: add
    path: /status
    value: 1
✓ Fixed
# Declare the field as type: integer or type: double before using add/sub.

VERR_REMOVE_TARGET_INVALID

Invalid REMOVE target. A remove op references a path that does not exist or cannot be removed.

Impact: Runtime error; intent fails.

✗ Won't compile
ops:
  - op: remove
    path: /nonexistent_field
✓ Fixed
# Verify the path exists in the entity schema.
# Use op: unset to clear optional scalar fields.

VERR_UNSET_REQUIRED_FIELD

UNSET on required field. A rule attempts to unset a field declared with required: true.

Impact: Entity would be left in an invalid state missing a required field.

✗ Won't compile
# order_id is required: true
ops:
  - op: unset
    path: /order_id
✓ Fixed
# Remove required: true from the field definition if it needs to be clearable,
# or remove the unset op if the field should always have a value.

VERR_FIND_WHERE_NOT_BOOLEAN

FIND where clause is not boolean. The where expression in a find op does not evaluate to a boolean.

Impact: Incorrect matching — all items may match or none may match.

✗ Won't compile
ops:
  - op: find
    path: /items
    where: "#{ item.quantity }"   # returns integer
✓ Fixed
ops:
  - op: find
    path: /items
    where: "#{ item.quantity > 0 }"

VERR_FOREACH_NOT_ITERABLE

FOR_EACH on non-iterable field. A for_each op targets a scalar or object field instead of an array.

Impact: Runtime throws; rule fails for every event.

✗ Won't compile
ops:
  - op: for_each
    path: /status    # string, not array
✓ Fixed
# Use for_each only on type: array fields.

VERR_IF_CONDITION_NOT_BOOLEAN

IF condition is not boolean. An if op’s condition expression returns a non-boolean value.

Impact: Condition is treated as truthy/falsy by the runtime with unpredictable results.

✗ Won't compile
ops:
  - op: if
    condition: "#{ entity.status }"   # string, not boolean
✓ Fixed
ops:
  - op: if
    condition: "#{ entity.status == 'active' }"

VERR_SORT_TARGET_NOT_SORTABLE

SORT on unsortable field. A sort op’s by field is an object, array, or other non-orderable type.

Impact: Sort produces an undefined ordering at runtime.

✗ Won't compile
ops:
  - op: sort
    path: /items
    by: /metadata    # object — not sortable
✓ Fixed
# Sort by a primitive field: string, integer, double, or timestamp.

Array Type Validation

VERR_SCHEMA_SHAPE_MISMATCH

Array field missing item schema. An array field declaration is missing item_type or item_fields when they are required.

Impact: Runtime cannot validate items pushed to the array; type safety is lost.

✗ Won't compile
fields:
  line_items:
    type: array        # missing item_type / item_fields
✓ Fixed
fields:
  line_items:
    type: array
    item_type: object
    item_fields:
      sku: { type: string }
      quantity: { type: integer }

VERR_ARRAY_EXPECTED

Array operation on non-array field. An array operation (push, for_each) targets a non-array field.

Impact: Runtime throws; intent fails.

✗ Won't compile
# status is type: string
ops:
  - op: push
    path: /status
    value: active
✓ Fixed
# Declare the field as type: array, or use op: set for scalars.

VERR_INVALID_ITEM_TYPE

Array item type mismatch. An item pushed to an array does not match the declared item_type.

Impact: Item is stored with the wrong type; queries and aggregates produce incorrect results.

✗ Won't compile
# line_items has item_type: object
ops:
  - op: push
    path: /line_items
    value: "SKU-001"    # string, not object
✓ Fixed
ops:
  - op: push
    path: /line_items
    value: { sku: "SKU-001", quantity: 1 }

VERR_MISSING_ITEM_FIELD

Required array item field missing. An object pushed to an array is missing a field declared as required in item_fields.

Impact: Entity state has incomplete array items; queries against missing fields return null.

✗ Won't compile
# item_fields: { sku: required, quantity: required }
ops:
  - op: push
    path: /line_items
    value: { sku: "SKU-001" }   # quantity missing
✓ Fixed
ops:
  - op: push
    path: /line_items
    value: { sku: "SKU-001", quantity: 1 }

VERR_INVALID_ITEM_FIELD_TYPE

Array item field type mismatch. An array item’s field value type does not match the item_fields schema.

Impact: Wrong type stored; aggregates and type-sensitive queries break silently.

✗ Won't compile
# quantity is type: integer
value: { sku: "SKU-001", quantity: "three" }
✓ Fixed
value: { sku: "SKU-001", quantity: 3 }

VERR_INVALID_ARRAY_WRITE

Invalid write to array field. A write operation to an array field uses the wrong op or value type.

Impact: Write is rejected or corrupts the array.

✗ Won't compile
# Attempting to set a scalar into an array field
ops:
  - op: set
    path: /tags
    value: "single-tag"
✓ Fixed
ops:
  - op: set
    path: /tags
    value: ["single-tag"]   # must be an array

VERR_INVALID_ARRAY_READ

Invalid read from array field. An expression reads from an array field using a path pattern that treats it as a scalar.

Impact: Expression evaluates to the array object itself instead of an element.

✗ Won't compile
# Treating /items as a scalar in an expression
value: "#{ entity.items }"   # returns the whole array
✓ Fixed
# Use find, for_each, or indexed access for array reads:
value: "#{ entity.items[0].sku }"

VERR_INVALID_ELEMENT_PATH

Invalid array element path syntax. An element path uses dot notation for array indices instead of bracket notation.

Impact: Path fails to resolve; op is silently skipped.

✗ Won't compile
ops:
  - op: set
    path: /items.sku     # dot notation is invalid for arrays
✓ Fixed
ops:
  - op: set
    path: /items[]/sku

VERR_INVALID_FOR_EACH

FOR_EACH on non-array. A for_each op targets a scalar or object field instead of an array field.

Impact: Runtime throws; rule fails.

✗ Won't compile
ops:
  - op: for_each
    path: /status    # string, not array
✓ Fixed
# Declare the field as type: array, or use for_each only on array fields.

VERR_REMOVE_REQUIRED_ARRAY

Removing required array field. A remove op targets an array field declared as required: true.

Impact: Entity left in an invalid state.

✗ Won't compile
# tags is required: true
ops:
  - op: remove
    path: /tags
✓ Fixed
# Set to an empty array instead of removing:
ops:
  - op: set
    path: /tags
    value: []