Make LOGV2 more resilient to logging the EOO element

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Fixed
    • Priority: Minor - P4
    • 8.1.0-rc0, 8.0.0-rc11
    • Affects Version/s: None
    • Component/s: None
    • Networking & Observability, Service Arch
    • Fully Compatible
    • v8.0, v7.3, v7.0, v6.0
    • Security 2024-07-08
    • 0
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None

      If we try to log an empty BSONElement, the logging system hits a MONGO_verify assertion. It is understandable that working with an empty BSONElement is not desired and should be caught through user error checking, but at the same time the following behavior difference is suprising:

      TEST(ExampleLogFailureTest, FailEOO) {
          BSONObj doc = BSON("id" << 123);
          LOGV2(12345, "Going to hit a MONGO_verify", "elem"_attr = doc["nonexistentField"]);    
      
          LOGV2(12345, "Works totally fine", "elem"_attr = doc["nonexistentField"].toString());
      } 

      We should consider making this behavior clearer at the logging level or make the EOO element print as a string.

            Assignee:
            Erin McNulty
            Reporter:
            Erin McNulty
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: