I'd start by looking in your templates and chunks for any [[~ ]] tags and making sure you're always giving them a number to work with. If you're using getResources, your tpl chunks probably have something like [[~[[+
somePlaceholder]]]] and if
somePlaceholder isn't getting set under certain circumstances, that would certainly cause the error you're seeing.
One thing to keep in mind is that the MODX parser works from the inside out. So if you have something like [[+
somePlaceholder:!empty=`[[~[[+
somePlaceholder]]]]`]] then [[~[[+
somePlaceholder]]]] is going to get evaluated first, whether or not
somePlaceholder is empty. If it's empty it won't be output, but it
will be evaluated and that'll generate your error.
This is a good article if you'd like to read more on the subject:
https://www.markhamstra.com/modx-blog/2011/11/nested-caching-in-modx-revolution/
Setting a default value is a good idea in these cases and a nice way of doing that is with chunk properties.