apex-async-processor
apex-async-processor copied to clipboard
Receive error when non-admin instantiates a class that extends AsyncProcessor
When a non-admin user instantiates a class that extends AsyncProcessor this error is received "Access to entity 'BatchApexErrorEvent' denied: Entity is not readable" I looked to add permissions to BatchApexErrorEvent but I cannot find an object with that name.
That's wild! I will have to take a look, thank you for reporting this
@jamessimone thanks for replying so quickly. I wrote a unit test to try to prove it, but the test ran without throwing an exception. In my org, I have a scheduled class that runs this code, so I had that user schedule the job and it ran without an error being thrown and the job is visible and running in Apex Jobs. To get the error I ran the code from Anonymous Apex in Developer Console as the user has permission to Author Apex so they can schedule the job.
@bbarlow-knauf apologies for the enormous delay in response. I had the same experience as you - tried to repro with a test but the test didn't have the same issue. That's an unfortunate shortcoming with System.runAs, it seems. I think your options here really come down to whether or not you can "promote" the running user, or whether or not abandoning the usage of BatchApexErrorEvent is the easier alternative for you. While I love the idea of one unified error event handling system, it's a significant downside if that comes at the cost of this class only being runnable by admins