openhab-webui icon indicating copy to clipboard operation
openhab-webui copied to clipboard

oh-repeater rulesWithTags does not work with multiple tags

Open m4rcu5 opened this issue 9 months ago • 0 comments

The problem

When filtering on multiple tags, by defining them as a comma separated list, as suggested by the oh-repeater documentation, there are no results returned.

Expected behavior

The expected return are all rules that match the combination of tags specified.

Steps to reproduce

- component: oh-repeater
  config:
    for: scene
    sourceType: rulesWithTags
    ruleTags: TagA,TagB

Results in the following API call: GET /rest/rules?summary=true&tags=TagA,TagB

Which does not return rules (scenes in my case) tagged with both TagA and TagB, but no results at all.

If only a single tag is specified this works as documented.

Your environment

runtimeInfo:
  version: 4.0.4
  buildString: Release Build

Additional information

Looking at the initial PR for this feature (#1724), it seems that the rulesWithTags is implemented the same way as itemsWithTags. However when looking into the API exporer to build these backend calls by hand, they seem to differ.

Example for items with multiple tags, which indeed seems to use coma separation: /rest/items?tags=Measurement,Level

Example for rules, which seems to expect the same query parameter multiple times: /rest/rules?tags=Scene&tags=TagA&tags=TagB

Doing a bit of query injection in the oh-repeater seems to confirm this suspicion.

- component: oh-repeater
  config:
    for: scene
    sourceType: rulesWithTags
    ruleTags: 'TagA&tags=TagB'

Returns the expected results, and the following API call: GET /rest/rules?summary=true&tags=TagA&tags=TagB

m4rcu5 avatar Nov 22 '23 12:11 m4rcu5