I went back and looked through topoh commit history and found this:
https://github.com/kamailio/kamailio/commit/78324dcc09d0a51fa02a960a40faa7fd...
After I applied the advice given therein, the error seems to have gone away. I assume this applies because CANCEL is also a locally generated request, since it is hop-by-hop.
However, I would be curious for some elaboration as to why this step is necessary and what connection the dialog module has to it.