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

Add log warning on challenge creation #2769

Merged
merged 8 commits into from Jun 10, 2021
Merged
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions privacyidea/lib/tokens/pushtoken.py
Expand Up @@ -860,9 +860,11 @@ def create_challenge(self, transactionid=None, options=None):
db_challenge.save()
self.challenge_janitor()

# If sending the Push message failed, we still raise an error.
# If sending the Push message failed, we still raise an error and a warning.
if not res:
raise ValidateError("Failed to submit message to firebase service.")
log.warning("Failed to submit message to firebase service for token {0!s}."
.format(self.token.serial))
Copy link
Member

Choose a reason for hiding this comment

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

I am sorry for my late comment.
I was not quite sure about this.

But in theory a serial number could contain a special character or a German umlaut. If we print it in the log message this way, we will raise an exception.
So we should do

log.warnung(u"Failed to .....".format())

To allow logging unicode.

Thanks a lot

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This should be fixed now.

raise ValueError("Failed to submit message to firebase service.")
Copy link
Member

Choose a reason for hiding this comment

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

Why did you change this to ValueError?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This really shouldn't be here because I already caught that one. I will fix it immediately.

else:
log.warning(u"The token {0!s} has no tokeninfo {1!s}. "
u"The message could not be sent.".format(self.token.serial,
Expand Down