Skip to content
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

System.LimitException: Regex too complicated from LogEntryEventBuilder.applyDataMaskRules: #639

Open
EnglundAndreas opened this issue Feb 20, 2024 · 3 comments
Labels
Feature: Data Masking Type: Bug Something isn't working

Comments

@EnglundAndreas
Copy link

Package Edition of Nebula Logger

Unlocked Package

Package Version of Nebula Logger

v4.12

New Bug Summary

I get an expected error when running a batch + queuable job due to locking error from a Query. So I have Nebula Logger that I want to log this error, but when it's trying to log my original error, I get an exception "System.LimitException: Regex too complicated".

Stack Trace from Nebula Logger (error is LogEntryEventBuilder.applyDataMaskRules):
Class.LogEntryEventBuilder.applyDataMaskRules: line 928, column 1
Class.LogEntryEventBuilder.setMessage: line 151, column 1
Class.Logger.error: line 838, column 1

@EnglundAndreas EnglundAndreas added the Type: Bug Something isn't working label Feb 20, 2024
@jongpie
Copy link
Owner

jongpie commented Feb 20, 2024

Hi @EnglundAndreas - do you know how long the string is that you're logging? And which parameters are you providing to Logger.error()? There are several overloads for that method (such as Logger.error(String), Logger.error(String, Exception), etc).

@EnglundAndreas
Copy link
Author

EnglundAndreas commented Feb 20, 2024

It should be about 35 000 characters, I'm serializing the scope from the batchjob as a JSON so it's a bit string. I have an abstract custom Retry class that I'm using to log errors and be able to retry them from the error record.

Here is the method that logs the error, where "this" is the class that

private void logError(Exception e) {
	RetryException retryException = new RetryException();
	String json = JSON.serializePretty(this, true);
	String errorMessage = 'Error occured from Retryable class: ' + this.getClassName() + '. Please view related error log entry to Retry.';
	if (parentLogTransactionId != null) {
		errorMessage = 'Error when running retry flow. See parent log for original transaction.';
		Logger.setParentLogTransactionId(parentLogTransactionId);
	}
	Logger.error(errorMessage, e);
	Logger.error(this.getClassName() + SEPARATOR + json, retryException);
	Logger.saveLog();
}

This is the class that is being serialized (the properties is variables that I use to rerun the method on errors):
`global class CreateInvoicesQueueable extends Retryable implements Queueable, Finalizer, Database.AllowsCallouts {
List scope;
Invoice_Batch_Job__c currentJob;
private String originalTransactionId;

	CreateInvoicesQueueable(List<Asset> scope, Invoice_Batch_Job__c currentJob, String originalTransactionId) {
		this.scope = scope;
		this.currentJob = currentJob;
		this.originalTransactionId = originalTransactionId;
	}
	global void execute(QueueableContext context) {
		Logger.setParentLogTransactionId(this.originalTransactionId);
		executeRetryable();
	}`

Since the scope of the batch with a size of 200, although only contains Ids, it still becomes a long string. So understandable that the logger does not support these big error messages.

@jongpie
Copy link
Owner

jongpie commented Feb 21, 2024

@EnglundAndreas thank you! This is really helpful info to have. I'm not sure how much I'll be able to optimize the regex for data masking, but I'll plan to do some analysis & testing to see what's possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature: Data Masking Type: Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants