System.tag.browse ignores filter parameter when the path is an AtomicTag?

I’m trying to use system.tag.browse function to recursively move up a folder structure until a certain UDT instance is found.

The function accepts a tagPath and returns the instance or None. It does this recursively, searching the current tagPath, else calling itself with the tagPath’s parent.

The syntax I’m using is:

	results = system.tag.browse(path = qualifiedPath, filter = {
		"name": "Device Config",
		"typeId": "Generic/Device Config",
		"tagType": "UdtInstance",

In my use case, this is called during in a notification pipeline, we’re trying to determine which team is responsible for this device and dynamically generate the on-call roster.

But the first time the notification pipeline calls this function, it’s passing it the tagPath of the tag that had the alarm on it. In the simplest case, it could be a memory tag with the path [default]test/memorytag.

Inside this tag, there shouldn’t be anything matching that filter. In my case, the instance of Device Config is in the same folder as memorytag ([default]test/Device Config)

When I run:

tagPath = "[default]test/memorytag"
results = system.tag.browse(path=tagPath, filter={"name": "Device Config","typeId": "Generic/Device Config","tagType": "UdtInstance",})

print "results for tagPath %s: %d" % (tagPath, results.getReturnedSize())

for result in results.getResults():
	print result["fullPath"]

I get the following output, but the filter should have removed all of these matches:

results for tagPath [default]test/memorytag: 17

It’s essentially ignoring the filter and returning the properties of that tag.

But when I run this on tagPath [default]test, the correct filtered results are shown (i.e. even though memorytag is within the folder, the result is filtered out):

results for tagPath [default]test: 1
[default]test/Device Config

It appears that system.tag.browse ignores the filter when a Memory Tag is used (perhaps all Atomic Tags, as I can reproduce it with an OPC tag as well), but correctly filters on a folder.

I realise the documentation says “The path that will be browsed, typically to a folder or UDT instance.”, and it appears to correctly work for folders and UDT instances.

Am I holding it wrong?

1 Like