MongoDB silently accepts empty string when creating a time-series collection

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Duplicate
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • None
    • None
    • None
    • None
    • None

      In src/mongo/db/shard_role/ddl/create_command.cpp:300-309, the validation block checks that metaField is not "_id", not equal to timeField, and has no dots — but doesn't checks that it's non-empty. So

       {timeseries: {timeField: "t", metaField: ""}} 

      succeeds silently.

      How the Failure Manifests

      A subsequent query like

        {$match: {a: 0}}

      on the collection returns [] instead of the correct [\{a: 0, ...}]. This is because downstream code throughout the timeseries stack (bucket predicate generation, bucket unpacking, splitOutMetaOnlyPredicate, isPathPrefixOf, etc.) is not designed to handle metaField = "" and behaves incorrectly or crashes (there's an explicit invariant(!metaField.empty()) in timeseries_update_delete_util.cpp:171).
       

            Assignee:
            Unassigned
            Reporter:
            Hagar Mohamed
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: