-
Notifications
You must be signed in to change notification settings - Fork 714
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
KeyError: "'type'" #1154
Comments
When using a logging method with positional or keyword arguments, Loguru will try to format your message. Example: logger.info("Value: {num}", num=42)
# Output: "Value: 42" I suppose the logger.error(
f"validation error {validation_error.errors()}",
extra_message=validation_error.errors(),
) The message is a f-string already formatted, but Loguru will tries to format it again due to the Maybe try the following instead: logger.error("validation error {extra_message}", extra_message=validation_error.errors()) |
Cool, I'll add this. Shouldn't loguru internally handle if the key doesn't exist in the string? |
That's not really possible (would imply re-implementing parsing and formatting of |
Cool, got it! Thanks Delgan. I'll be closing this issue. |
Receiving KeyError when using logger with no patching. Occuring in
loguru/_logger.py#L2021
Maybe similar to #1008.
The code is something like this:
the
another_logger
is just to view what's happening inside thelogger
before it errors out. You can create simple Pydantic model and try validating it in order to recreate this issue.A simple test in notebook gave me, "'type'" is expected in string to be formatted, but it doesn't exist. How is it possible?
Error:
The text was updated successfully, but these errors were encountered: