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

Improve exception serializing #35970

Merged
merged 3 commits into from
Jan 16, 2023
Merged

Conversation

juliushaertl
Copy link
Member

@juliushaertl juliushaertl commented Jan 3, 2023

Summary

Small improvement to not start serializing an exception during logging if the log level would skip it anyways. Noticed when seeing errors due to Nesting level too deep - recursive dependency? at /var/www/html/lib/private/Log/ExceptionSerializer.php#215 while there was no actual error logged when commenting out the argument cleanup

The second commit avoids such cases by handling the arguments first (which limits to a recursion depth of 5) before iterating over them for filtering for sensitive parameters.

Checklist

@juliushaertl juliushaertl requested review from a team, ArtificialOwl, icewind1991, blizzz and PVince81 and removed request for a team January 3, 2023 18:05
@juliushaertl juliushaertl added the 3. to review Waiting for reviews label Jan 3, 2023
@juliushaertl juliushaertl changed the title perf(logging): Return early when log level does not match before serializing an exception Improve exception serializing Jan 3, 2023
@szaimen szaimen added this to the Nextcloud 26 milestone Jan 3, 2023
@solracsf
Copy link
Member

solracsf commented Jan 4, 2023

Does this fix #32432 and #35413?

@juliushaertl
Copy link
Member Author

Does this fix #32432 and #35413?

Likely doesn't fix it but would lead to getting a proper error message instead of the generic error caused within the logging parts.

@juliushaertl
Copy link
Member Author

Or wait, it may still help if the error was not logged due to a lower log level.

@PhrozenByte
Copy link
Contributor

Should also fix (resp. circumvent) #23429

Copy link
Member

@ChristophWurst ChristophWurst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 :shipit: otherwise

@@ -312,6 +312,11 @@ public function logException(Throwable $exception, array $context = []) {
$app = $context['app'] ?? 'no app in context';
$level = $context['level'] ?? ILogger::ERROR;

$minLevel = $this->getLogLevel($context);
if ($level < $minLevel && !$this->crashReporters->hasReporters()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$this->crashReporters needs a null check

Copy link
Member

@blizzz blizzz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wondering about #35970 (comment)

…alizing an exception

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This will avoid running into a Nesting level too deep error as the
encodeArg calls will limit potential recursive calls on the arguments to
a nesting level of 5

Signed-off-by: Julius Härtl <jus@bitgrid.net>
Signed-off-by: Julius Härtl <jus@bitgrid.net>
@juliushaertl juliushaertl removed the 3. to review Waiting for reviews label Jan 16, 2023
@juliushaertl juliushaertl added bug 4. to release Ready to be released and/or waiting for tests to finish performance 🚀 labels Jan 16, 2023
@juliushaertl juliushaertl merged commit 8557c61 into master Jan 16, 2023
@juliushaertl juliushaertl deleted the perf/noid/exception-serializer branch January 16, 2023 13:00
@juliushaertl
Copy link
Member Author

/backport 7daa20d to stable25

@juliushaertl
Copy link
Member Author

/backport 7daa20d to stable24

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4. to release Ready to be released and/or waiting for tests to finish bug performance 🚀
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants