NVIDIA / NeMo-Guardrails

NeMo Guardrails is an open-source toolkit for easily adding programmable guardrails to LLM-based conversational systems.
Other
3.72k stars 325 forks source link

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

Open munircontractor opened 1 week ago

munircontractor commented 1 week ago

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()
drazvan commented 1 week ago

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