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

mongos collMod command does not validate its reply

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 4.9.0
    • Affects Version/s: None
    • Component/s: Replication
    • Labels:
      None
    • Minor Change
    • ALL
    • Repl 2021-02-22

      I think there's a bug in cluster_collection_mod_cmd.cpp:

          void validateResult(const BSONObj& resultObj) final {
              auto ctx = IDLParserErrorContext("CollModReply");
              StringDataSet ignorableFields(
                  {kWriteConcernErrorFieldName, ErrorReply::kOkFieldName, kTopologyVersionFieldName});
              if (!checkIsErrorStatus(resultObj, ctx)) {
                  if (resultObj.hasField(kRawFieldName)) {
                      const auto& rawData = resultObj[kRawFieldName];
                      if (ctx.checkAndAssertType(rawData, Object)) {
                          for (const auto& element : rawData.Obj()) {
                              const auto& shardReply = element.Obj();
                              if (!checkIsErrorStatus(shardReply, ctx)) {
                                  auto reply =
                                      Reply::parse(ctx, shardReply.removeFields(ignorableFields));
                                  coll_mod_reply_validation::validateReply(reply);
                              }
                          }
                      }
                  } else {
                      auto reply = Reply::parse(ctx, resultObj.removeFields(ignorableFields));
                      coll_mod_reply_validation::validateReply(reply);
                  }
              }
          }
      

      That will not call Reply::parse if the reply includes a "raw" field. Thus I think Reply::parse is never called?

            Assignee:
            m.maher@mongodb.com Moustafa Maher
            Reporter:
            jesse@mongodb.com A. Jesse Jiryu Davis
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: