Unable to use BSON serializer/deserializer in a nested namespace

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Gone away
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Server Programmability
    • Programmability 2025-07-21, Programmability 2025-08-04
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Given an IDL defined in the namespace mongo (i.e. set to global.cpp_namespace) that defines a customer type with the serializer/deserializer functions in a nested namespace (e.g., mongo::util), the generated code doesn't take into account the specified namespace for the serializer/deserializer functions, causing a symbol not found error at compiling time.

      More in details, given the following IDL:

      global:
          cpp_namespace: "mongo"
      ...
      
      types:
          status:
              bson_serialization_type: any
              cpp_type: "mongo::Status"
              serializer: "mongo::util::serializeStatusToBSON"
              deserializer: "mongo::util::deserializeStatusFromBSON"
      ...
      
      structs:
          CoordinatorMetadata
          ...
          fields:
              error:
                  type: status

      The compiler generates the following code:

      namespace mongo {
      ...
      
      void CoordinatorMetadata::serialize(BSONObjBuilder* builder) const {
      ...
          if (_error) {
              serializeStatusToBSON((*_error), kErrorFieldName, builder);
          }
      ...
      }}

      The problem is that the function serializeStatusToBSON is defined in the namespace mongo::util, not in mongo.

            Assignee:
            Eduardo Lopez (Inactive)
            Reporter:
            Antonio Fuschetto
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: