Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-91891

Make LOGV2 more resilient to logging the EOO element

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

      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@mongodb.com Erin McNulty
            Reporter:
            erin.mcnulty@mongodb.com Erin McNulty
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: