Uploaded image for project: 'Compass '
  1. Compass
  2. COMPASS-5015

Duplicating View in Compass picks up the view's source collection's name as the DB name

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 1.29.4
    • Affects Version/s: 1.28.1
    • Component/s: Compass
    • None
    • 3
    • Not Needed
    • Iteration Kampala

      Problem Statement/Rationale

      In Compass, when you click on the eillipsis next to a View, click "Duplicate View", enter some view name, and click the "Duplicate" button, then it throws an error. The error that it throws depends on the role and privileges the user has, but the *root-cause of the error is same*. Specifically, the "Duplicate View" functionality erroneously tries to duplicate the view in a database whose name is the view's source collection's name.

      For example, consider this test collection called survey:

      PRIMARY> db.survey.find()
      { "_id" : 1, "empNumber" : "abc123", "feedback" : { "management" : 3, "environment" : 3 }, "department" : "A" }
      

      I created a view named managementFeedback on the above collection:

      PRIMARY> db.createView(
      ...    "managementFeedback",
      ...    "survey",
      ...    [ { $project: { "management": "$feedback.management", department: 1 } } ]
      ... )
      {
      	"ok" : 1,
      	"$clusterTime" : {
      		"clusterTime" : Timestamp(1629140171, 1),
      		"signature" : {
      			"hash" : BinData(0,"bHBmefZ5gCFjO5/HT+tLSkRxA2Q="),
      			"keyId" : NumberLong("6940972140258656257")
      		}
      	},
      	"operationTime" : Timestamp(1629140171, 1)
      }
      
      MongoDB Enterprise HDFTS-shard-0:PRIMARY> db.managementFeedback.find()
      { "_id" : 1, "department" : "A", "management" : 3 }
      

      As you can observe above, survey is the name of the collection.

      Now, from Compass versions 1.25.0 as well as 1.28.1, if I try to duplicate the collection, I get errors. The error that I get if I login to Compass as user with admin level privileges, is as follows:

      Invalid input namespace, survey.
      

      And the error that I get if I login to Compass as user with non-admin level privileges, is as follows:

      not authorized on survey to execute command { create: "xyz", viewOn: "", pipeline: [ { $project: { management: "$feedback.management", department: 1 } } ], lsid: { id: UUID("1af90bb8-52be-41f4-afb7-7361347ed059") }, $clusterTime: { clusterTime: Timestamp(1629153553, 1), signature: { hash: BinData(0, AA0B7505B09DD8AF43F8347FF1ABA5F704900771), keyId: 6940972140258656257 } }, $db: "survey" }
      

      Note above in both errors that the dbname shows as survey. In other words, Compass erroneously tries to duplicate the view in a database whose name is the view's source collection's name.
       

      Steps to Reproduce

      • Create a view on a collection.
      • From Compass > click on the ellipsis next to the View name > click "Duplicate View" > enter some view name > click the "Duplicate" button.

      Expected Results

      Compass should not choose the view's source collection's name as the DB name for creating the duplicated view, and the View should be duplicated correctly and successfully.

      Actual Results

      The view creation fails with the above errors.

      Additional Notes

      Observed in Compass versions 1.25.0 as well as 1.28.1.

            Assignee:
            rhys.howell@mongodb.com Rhys Howell
            Reporter:
            harshad.dhavale@mongodb.com Harshad Dhavale
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: