NeMo-Guardrails icon indicating copy to clipboard operation
NeMo-Guardrails copied to clipboard

Error in `VerboseHandler` when `::` present in log messages but not ` :: `.

Open mun1r0b0t opened this issue 1 year ago • 1 comments

This line checks whether there is a :: in the message but the line after it splits on " :: ", with spaces around the colons.

If the message contains an IPv6 address (or anything else) with :: in it but no surrounding spaces, it results in an error. It might be better to check for " :: " in the if condition, since that is really what is expected in the split call later.

diff --git a/nemoguardrails/logging/verbose.py b/nemoguardrails/logging/verbose.py
index ac0cab12..b5b8dcdb 100644
--- a/nemoguardrails/logging/verbose.py
+++ b/nemoguardrails/logging/verbose.py
@@ -41,8 +41,8 @@ class VerboseHandler(logging.StreamHandler):
     def emit(self, record) -> None:
         msg = self.format(record)
 
-        # We check if we're using the spacial syntax with "::" which denotes a title.
-        if "::" in msg:
+        # We check if we're using the special syntax with " :: " which denotes a title.
+        if " :: " in msg:
             title, body = msg.split(" :: ", 1)
             title = title.strip()

mun1r0b0t avatar Jun 18 '24 20:06 mun1r0b0t

Thanks for reporting this @munircontractor. I thought this was fixed as this was raised before. We'll fix for 0.10.0.

drazvan avatar Jun 19 '24 08:06 drazvan

Hey @drazvan, seems like this is fixed by you. Can the issue be closed.

SSK-14 avatar Oct 14 '24 05:10 SSK-14

Fixed in #603.

trebedea avatar Oct 14 '24 09:10 trebedea