Uploaded image for project: 'C Driver'
  1. C Driver
  2. CDRIVER-587

URI parsing logs warning on w < -1 but otherwise ignores it

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • TBD
    • Affects Version/s: 1.1.2
    • Component/s: None
    • None

      While adding validation for journal and w=0 or w=-1 conflict for CDRIVER-580, I noticed that parsing for values of w less than -1 are ignored apart from a logged error. This means that URI parsing can still succeed.

      I don't think it's possible to fail during _mongoc_uri_build_write_concern(), which stores parsed options on the write concern struct, as that function provides no API for relaying an error upstream. That's why my PR in CDRIVER-580 validated the write concern one level up in mongoc_uri_new().

      That said, I think we could easily catch an invalid w value in mongoc_uri_parse_option(), which does allow us to return false on an error. The relevant code segment would be:

      if (*value == '-' || isdigit(*value)) {
         v_int = (int) strtol (value, NULL, 10);
         BSON_APPEND_INT32 (&uri->options, "w", v_int);
      }
      

            Assignee:
            backlog-c-driver [DO NOT USE] Backlog - C Driver Team
            Reporter:
            jmikola@mongodb.com Jeremy Mikola
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: