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

Shard key field validation for DBRefs prohibits extra dollar-prefixed fields

    • Type: Icon: Bug Bug
    • Resolution: Works as Designed
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 7.1.0-rc0, 7.0.0-rc1, 6.0.7, 5.0.19, 4.4.23
    • Component/s: None
    • None
    • ALL

      While looking back on 10gen/mongo#12776 for SERVER-76948, I realized the field validation to allow DBRefs as shard keys may still be too strict.

      That patch only allows "$ref", "$id", and "$db" fields explicitly. There are no restrictions on DBRefs containing additional fields thereafter, and those fields may be dollar-prefixed following 5.0 project to allow dots and dollars in field names (e.g. SERVER-49117). In the interest of backwards compatibility for users that may already be sharding on DBRefs containing additional dollar-prefixed fields, the validation in parseShardKeyPattern should be relaxed.

      Beyond DBRefs, is there any reason a document like the following cannot be used as a shard key?

      { "$foo": 1 }
      

      Looking back at SERVER-74124, it seems that the original intention was just to prohibit the special "$**" field name, so perhaps the validation can check for that explicitly.

      Note for triage: I entered all of the "Fix Versions" from SERVER-76948 as the "Affects Version" for this ticket, but some of those are still unreleased. Please adjust accordingly.

            Assignee:
            Unassigned Unassigned
            Reporter:
            jmikola@mongodb.com Jeremy Mikola
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: