# System.tag.exists ..... but it doesn't

**URL:** <https://forum.inductiveautomation.com/t/system-tag-exists-but-it-doesnt/53271>\
**Category:** Ignition\
**Tags:** scripting\
**Created:** [November 19, 2021, 1:22am UTC](https://forum.inductiveautomation.com/t/system-tag-exists-but-it-doesnt/53271 "2021-11-19T01:22:34Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![markrit](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/markrit/32/29635_2.png) [@markrit](https://forum.inductiveautomation.com/u/markrit)\
**Post date:** [November 19, 2021, 1:22am UTC](https://forum.inductiveautomation.com/t/system-tag-exists-but-it-doesnt/53271/1 "2021-11-19T01:22:34Z")

</div>

If I run the following in the script console

```
gnamePath = '[MQTT Engine]DCNET/MAP/S1/R1/B1/G10/Name'
if system.tag.exists (gnamePath):
	print 'Tag Exists'

```

and a folder for [MQTT Engine]DCNET/MAP/S1/R1/B1/G10/ is present , BUT the tag “Name” is NOT present in that folder then this will print " Tag Exists"

The function description is  
Checks whether or not a Tag with a given path exists.

The folder has no tags in it is this the problem?

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [November 19, 2021, 1:52am UTC](https://forum.inductiveautomation.com/t/system-tag-exists-but-it-doesnt/53271/2 "2021-11-19T01:52:54Z")

</div>

What version of Ignition is this happening on?

---

<div class="post-metadata">

**Author:** ![markrit](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/markrit/32/29635_2.png) [@markrit](https://forum.inductiveautomation.com/u/markrit)\
**Post date:** [November 19, 2021, 3:46pm UTC](https://forum.inductiveautomation.com/t/system-tag-exists-but-it-doesnt/53271/3 "2021-11-19T15:46:08Z")

</div>

8.1.7

---

<div class="post-metadata">

**Author:** ![markrit](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/markrit/32/29635_2.png) [@markrit](https://forum.inductiveautomation.com/u/markrit)\
**Post date:** [November 19, 2021, 5:53pm UTC](https://forum.inductiveautomation.com/t/system-tag-exists-but-it-doesnt/53271/4 "2021-11-19T17:53:17Z")

</div>

Updated to 8.1.12 now getting this message

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/d/e/de396ef6048590f2f3add8f0fcd06dce110cb871.png)

only file in this path is modules file. Tried uninstalling, and downloading designer for reinstall. No luck

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [November 19, 2021, 6:01pm UTC](https://forum.inductiveautomation.com/t/system-tag-exists-but-it-doesnt/53271/5 "2021-11-19T18:01:50Z")

</div>

Delete the `11.0.11.1` folder in that path and you should be able to launch.

---

<div class="post-metadata">

**Author:** ![markrit](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/markrit/32/29635_2.png) [@markrit](https://forum.inductiveautomation.com/u/markrit)\
**Post date:** [November 19, 2021, 6:21pm UTC](https://forum.inductiveautomation.com/t/system-tag-exists-but-it-doesnt/53271/6 "2021-11-19T18:21:22Z")

</div>

That fixed the designer launch after upgrade .

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/6/3629a2a81df58d98607b456e5f1361af4fde2fc9.png)

Still have issue with system.tag.exists

---

<div class="post-metadata">

**Author:** ![WillMT10](https://avatars.discourse-cdn.com/v4/letter/w/7feea3/32.png) [@WillMT10](https://forum.inductiveautomation.com/u/WillMT10)\
**Post date:** [November 19, 2021, 6:31pm UTC](https://forum.inductiveautomation.com/t/system-tag-exists-but-it-doesnt/53271/7 "2021-11-19T18:31:42Z")

</div>

Have you tried refreshing the tag provider to make sure the folder is actually empty? I just ran a test in 8.1.9 and it worked as expected for me (empty folder and returned false when I checked for a non-existent tag in the empty folder).

Edit: Just wanted to note that the provider I tested against does not use MQTT.

---

<div class="post-metadata">

**Author:** ![markrit](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/markrit/32/29635_2.png) [@markrit](https://forum.inductiveautomation.com/u/markrit)\
**Post date:** [November 19, 2021, 6:52pm UTC](https://forum.inductiveautomation.com/t/system-tag-exists-but-it-doesnt/53271/8 "2021-11-19T18:52:27Z")

</div>

Yes. Did this in the tag browser same results.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [November 19, 2021, 7:11pm UTC](https://forum.inductiveautomation.com/t/system-tag-exists-but-it-doesnt/53271/9 "2021-11-19T19:11:59Z")

</div>

I think this might be a bug that is specific to the MQTT modules.

I thought maybe it affected any ManagedTagProvider implementation but I just tested against the provider from the SDK example and it works as expected.

I’d contact Cirrus Link or maybe paging @wes0johnson will work 🙂

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/9/6/96a21dda6b3e880523eaac55636a9af5a85a4a86.png)

---

<div class="post-metadata">

**Author:** ![wes0johnson](https://avatars.discourse-cdn.com/v4/letter/w/7ab992/32.png) [@wes0johnson](https://forum.inductiveautomation.com/u/wes0johnson)\
**Post date:** [November 19, 2021, 8:59pm UTC](https://forum.inductiveautomation.com/t/system-tag-exists-but-it-doesnt/53271/10 "2021-11-19T20:59:45Z")

</div>

This is not something I’ve seen before. I’m not sure how the MQTT Engine module could be causing this other than maybe with the way we configure the ManagedTagProvider. I believe some of the config options we use are different from the SDK example. I’ll take a look and see if I can repro this and isolate the cause.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [November 19, 2021, 9:00pm UTC](https://forum.inductiveautomation.com/t/system-tag-exists-but-it-doesnt/53271/11 "2021-11-19T21:00:57Z")

</div>

`system.tag.exists` expects QualityCode Bad\_NotFound to be returned after trying to read a tag that doesn’t exist.

---

<div class="post-metadata">

**Author:** ![wes0johnson](https://avatars.discourse-cdn.com/v4/letter/w/7ab992/32.png) [@wes0johnson](https://forum.inductiveautomation.com/u/wes0johnson)\
**Post date:** [November 19, 2021, 10:06pm UTC](https://forum.inductiveautomation.com/t/system-tag-exists-but-it-doesnt/53271/12 "2021-11-19T22:06:45Z")

</div>

Is this not something that is handled by the ManagedTagProvider itself? I just glanced at the SDK example and it doesn’t do anything explicitly around this that I can see…

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [November 19, 2021, 10:21pm UTC](https://forum.inductiveautomation.com/t/system-tag-exists-but-it-doesnt/53271/13 "2021-11-19T22:21:29Z")

</div>

Well, that’s what I thought, but like I said when I tested the MTP example it all works fine 😕

I’m not sure why it’s not behaving the same for tags from the MQTT provider.

---

<div class="post-metadata">

**Author:** ![wes0johnson](https://avatars.discourse-cdn.com/v4/letter/w/7ab992/32.png) [@wes0johnson](https://forum.inductiveautomation.com/u/wes0johnson)\
**Post date:** [November 19, 2021, 10:39pm UTC](https://forum.inductiveautomation.com/t/system-tag-exists-but-it-doesnt/53271/14 "2021-11-19T22:39:34Z")

</div>

I’ll do some digging on my side and see what I can find.

---

<div class="post-metadata">

**Author:** ![wes0johnson](https://avatars.discourse-cdn.com/v4/letter/w/7ab992/32.png) [@wes0johnson](https://forum.inductiveautomation.com/u/wes0johnson)\
**Post date:** [November 24, 2021, 1:04am UTC](https://forum.inductiveautomation.com/t/system-tag-exists-but-it-doesnt/53271/15 "2021-11-24T01:04:37Z")

</div>

So I think I figured this out. I was not able to reproduce with the SDK example, but I was with Engine. This is how I got it to happen:

1. I created an Edge Node with 3 tags under a single device and published from Transmission
2. I deleted one of the tags from the Edge side
3. I restarted MQTT Engine (this is key)
4. I published a new birth from the Edge

This produced the following:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/1/3/13068f0f8a27ccbde0bf9f56bc68f3d59fd93786.png)

The reason is that MQTT Engine does not persist tags. But, it does still persist the tag configuration. So, I think ‘tagExists’ looks to see if it is in the DB tag table - which does not necessarily mean it is visible in Designer. With this, I suspect the tag you are trying to look up did exist at one point and was never deleted from the Ignition Tag DB (via a delete event or similar). But, Engine has since been restarted which is why it is not visible in Designer.

I believe that if you delete that tag from the DB, tagExists will properly return false.
