Yeah looks like mainPid is somehow missing you can check the admin>advanced>events log to see if someone deleted post 36210. Can also check if its still in the database by
The problem was I was deleting tags that no longer had topics but was doing it in the wrong place. If a user couldn't see any topics the code was deleting the tag. I moved it up to actually check the tids and not the topics the user can see.