Formatted Partial Filter Expression is not accepted on index creation

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Unresolved
    • Priority: Major - P3
    • None
    • Affects Version/s: 1.42.3
    • Component/s: None
    • None
    • Environment:
      OS: MacOS 14.2.1
    • 3
    • None
    • None
    • Developer Tools

      Problem Statement/Rationale

      In MongoDB Compass, when inputting a valid JSON object into the partialFilterExpression field for index creation, using the UI's "format" button results in the automatic removal of quotation marks from JSON keys. This behavior transforms the JSON from a valid format to an invalid one. Specifically, after entering a correct JSON structure with quotation marks around keys and string values (as required by JSON standards) and then clicking the "format" button, the formatted JSON erroneously lacks quotation marks around the keys.

      Attempting to proceed with the index creation after formatting results in a syntax error: "Bad PartialFilterExpression: SyntaxError: Expected property name or '}' in JSON at position 4 (line 2 column 3)." This issue suggests a bug in the formatting function that affects usability, particularly for creating indexes with partial filter expressions directly through the UI. The desired action is for the Engineering team to correct the formatting feature to preserve the validity of JSON structures, including retaining quotation marks where they are necessary.

      Or if it is supposed to be a plain object, then an error should not be thrown on valid plain object and JSON format should not be accepted. I am not sure of the intended behavior and regardless a consistent, working behavior is expected.

      Please be sure to attach relevant logs with any sensitive data redacted.
      How to retrieve logs for: Compass; Shell

      Steps to Reproduce

      Please see the attached screen recording.

      Expected Results

      I expect Compass accepts the formatting it performs.

      Actual Results

      Compass fails to accept its own formatting and instead I have to manually add quotation marks around the keys of the expression.

      Additional Notes

        1. mongodb-compass-partial-filter-expression.mov
          3.89 MB
          Tiny Talk
        2. mongodb-compass-partial-filter-expression.txt
          39 kB
          Tiny Talk
        3. Screenshot 2025-03-15 at 18.09.04.png
          302 kB
          Tiny Talk

            Assignee:
            Unassigned
            Reporter:
            Tiny Talk
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: