-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Exception when Request.getCurrent().getRequestId() is null #67
Comments
Not sure if this helps, but I have a trigger on the User record to do something and I have logger entries in the class that does it. This usually works fine when an admin updates a user record through setup. But I recently exposed the field that triggers this class on Advanced User Details so user can edit this field themselves. This is when the error is seen so not sure if saleforce is doing something weird here. |
Hi @mikbranchaud , Sorry for the late reply, December was extremely busy and I had no time to pay attention to the library. The issue that you reported seems off to me and I think it would be good to open a ticket with Salesforce about it. It is my understanding that the Request ID should never be NULL, so I would be interested to know under what circumstances that would be legit? Here is the documentation for reference, it does not indicate that the value could be NULL: https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_System_Request.htm#apex_System_Request_getCurrent Either way, I will update the logger to handle this edge case and will add "NULL" as a string if the request ID is not available. I am close to finishing another feature shortly. The fix should be ready before returning to work in the coming year. Thanks again for your message and using the framework! Cheers, |
…ch causes a NullPointerException in the default logger. If the request ID is null, a "NULL" string will be used as the request ID instead.
Releases 4.1 has been published. Thanks for submitting this issue |
Describe the bug
I have seen intermittent occasions where this line (rflib_DefaultLogger.reportLogs) errors:
Request_ID__c = requestId.substring(0, Math.min(requestId.length(), 40)),
with:
System.NullPointerException: Attempt to de-reference a null object
The first time it happened it was only in my sandbox and I made a temporary change to set Request_ID__c another way but just figured it was a fluke. This is now occurring in our shared dev environment so there seems to be some combination of circumstance that leads to this
Seems to only be occurring right now on one particular trigger which is on the User record (I dont remember the trigger this occurred on the first time)
Version
What version are you using? Did you make any modifications to the code?
Code Snippets
String requestId = Request.getCurrent().getRequestId();
rflib_Log_Event__e eventToLog = new rflib_Log_Event__e(
Request_ID__c = requestId.substring(0, Math.min(requestId.length(), 40)),
Log_Level__c = logLevel.toString(),
Context__c = context.substring(0, Math.min(context.length(), 40)),
Log_Messages__c = messageSize < MAX_MESSAGE_SIZE
? maskedLogMessagesIfApplicable
: maskedLogMessagesIfApplicable.substring(messageSize - MAX_MESSAGE_SIZE)
);
Expected behavior
I dont know why Request.getCurrent().getRequestId() would be null but if there is a setting I need to make to make it never null, or a backup to generate a unique Id on the occasion it is null
Screenshots
If applicable, add screenshots to help explain your problem, i.e. Chrome Dev Console.
The text was updated successfully, but these errors were encountered: