Skip to content

AssetsFacade.dispatch rejects batches with multiple events for the same asset #3476

Open

Description

@ebariaux

Description

AssetsFacade.dispatch(AttributeEvent... events) rejects valid batches containing multiple events for the same asset. This is a functional bug discovered during the rules-facade scoping audit (#2675).

The facade collects one asset ID per event, queries accessible assets, and compares the number of supplied IDs with the number of assets returned. Repeated IDs only match one database row, so a valid batch is rejected with an access warning and no events are dispatched.

Reproduction

From a Groovy rule, dispatch two updates to different attributes of the same existing asset within the engine's scope (replace the ID and attributes with valid ones):

assets.dispatch(
    new AttributeEvent("asset-A", "targetTemperature", 21),
    new AttributeEvent("asset-A", "enabled", true)
)

The validation compares two event IDs with one matching asset and rejects both updates. The same problem affects batches mixing repeated and distinct asset targets.

Expected behavior

Validate the distinct target asset IDs against the engine scope, then forward every original event in its supplied order. If any target is missing or outside the scope, reject the entire call before forwarding any events.

This preserves the existing global, realm and asset-subtree access rules. Event processing remains asynchronous; batch dispatch does not promise transactional attribute updates.

Acceptance Criteria

  • Add a failing regression test before implementing the fix: two events for different attributes of one permitted asset must both be forwarded.
  • Cover a valid batch containing both repeated and distinct target asset IDs, preserving every event and its dispatch order.
  • Cover global, realm and asset-scoped engines.
  • Confirm that a batch containing a missing or out-of-scope target forwards no events, including when other target IDs are repeated.
  • Deduplicate only the asset IDs used for validation, not the events dispatched.

Implementation Notes

Affected code: manager/src/main/java/org/openremote/manager/rules/facade/AssetsFacade.java, batch dispatch method.

Groovy rules can call this batch overload directly. JSON rule actions currently dispatch individual events, so they do not normally encounter this defect.

Activity

  1. self-assigned this
    on Oct 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

BugError or issue in the system

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions