When I'm working in the Keyboard Maestro app, I randomly get a pop up message saying "Failed to export macros. The attempt to export the macros failed, the macros have not been exported." However I didn't initiate any export of macros and I don't have any macro who would automatically do that—neither the debug window (if it's open when I get that error message) or the logs show any trace / activity who would be initiating such export. Is there a hidden preferences that controls that, or is this a bug?
The KM Editor has its own log file, and the KM Engine has its own log file. You should check both log files. Both log files are available by using the KM Editor's Help / Open Log Folder action.
If there is a feature in the Editor that could cause this (and I'm not sure if there is, however the Editor does autosave macros, so it's possible) then you may see more details in the Editor.log file. If there is a macro that is causing this (which might be the case) then you may see more details in the Engine.log file.
If there is no information in those files, then you may have to indicate what version of KM you are using and what version of macOS you are using.
I have no idea what would be going on with that, Keyboard Maestro wont be exporting anything unless it is asked too, so either there is something asking it to, or perhaps an incorrect error is being displayed.
I suggest you take a screenshot of the error, and email it to me (Stairways Software: Contact Us).
I get the same thing and have been for the past month or so and finally just thought I would get on here to see if anyone has any idea. I sent a message to the email as well. I am not trying to export and when I run a search or any macros it randomly pops up several times a day in Keyboard Maestro. I searched recent macros and there is nothing that is trying to export macros and it is inconsistent I can run the same macro twice that generated the error and get it twice and then not get it again the next several times I run the same macro in Keyboard Maestro.

Yes, I have an idea. Check the log files (both of them) to see if there's more information.
Also, you may want to expand what you mean by "when I run a search or any macros". Is there a typo in there?