appsmithorg / appsmith

Platform to build admin panels, internal tools, and dashboards. Integrates with 25+ databases and any API.
https://www.appsmith.com
Apache License 2.0
34.14k stars 3.7k forks source link

MongoDB collections (structure) not browsable in dropdown menu, querying only possible in "raw" mode #33642

Closed SplendidFarzad closed 4 months ago

SplendidFarzad commented 4 months ago

Is there an existing issue for this?

Description

I have two docker containers. One is a standalone MongoDB container. The other is the latest version of AppSmith (v1.25). The mongodb container is accepted as datasource in AppSmith, but the structure is not viewable. Only in raw mode, I can perform actions or run queries on the collections. Therefore, other operations like find documents, that are accompanied by the dropdown menu for selecting the collection are not usable. I am using the root user, which has full access to all databases: readWrite/owner etc.

Steps To Reproduce

  1. Datasource tested and added
  2. Find documents: selecting collection is not possible due to the structure not having been fetched
  3. Only Raw querying possible (fast and successful)

Public Sample App

No response

Environment

Production

Severity

High (Blocker to building or releasing)

Issue video log

https://internal.mobrog.com/pastebin/fba409c5-70f4-49b3-94de-13098ae370f7.avi

Version

Self Hosted v1.25

Nikhil-Nandagopal commented 4 months ago

@SplendidFarzad thank you for raising this. Can you tell me how many collections does your mongo database have?

SplendidFarzad commented 4 months ago

One Database containing 8 views and 8 collections.

SplendidFarzad commented 4 months ago

@Nikhil-Nandagopal Any updates?

sneha122 commented 4 months ago

Hi @SplendidFarzad Thanks a lot for reporting this issue! Is it possible to share the screenshot of network tab (in browser dev console) when you create a new mongo query using this datasource?

You can also get the logs using this link, If you can provide the logs, it will be helpful to debug the issue further.

SplendidFarzad commented 4 months ago

Logs: logs.zip Screenshot: https://internal.mobrog.com/pastebin/dfe40cbb-b139-4d0c-8ccd-0dfea45c8e9c.png Rercording: https://internal.mobrog.com/pastebin/b0672487-9ac9-46a7-b8f4-e3ba69d4a64c.avi

Attached. What do you think is the issue here?

sneha122 commented 4 months ago

Hi @SplendidFarzad Thanks a lot for sharing these logs, I will check these and get back to you!

sneha122 commented 4 months ago

@SplendidFarzad In the logs, I am seeing this error Appsmith has failed to get database structure. Please provide read permission on the database to fix this., could you please confirm that sufficient permissions have been given in mongoDB?

SplendidFarzad commented 4 months ago

All permissions are correctly set as I am using the root user (which is the only existing user in the Mongo instance) to connect AppSmith.

Here is the log of permissions from Mongo shell:

[
  {
    _id: 'admin.root',
    userId: UUID('cc9f1bb0-70ca-4bb5-b8a5-9680a6bcb126'),
    user: 'root',
    db: 'admin',
    roles: [
      {
        role: 'root',
        db: 'admin'
      },
      {
        role: 'dbOwner',
        db: 'splendid'
      },
      {
        role: 'dbAdmin',
        db: 'splendid'
      },
      {
        role: 'readWrite',
        db: 'splendid'
      },
      {
        role: 'userAdmin',
        db: 'splendid'
      }
    ],
    mechanisms: [
      'SCRAM-SHA-1',
      'SCRAM-SHA-256'
    ]
  }
]

How shall I proceed?

sneha122 commented 4 months ago

@SplendidFarzad Would you be able to provide the connection string you are using to create this mongoDB datasource? You can redact the password. I want to ensure that mongo connection string is correctly reflecting the appropriate database name.

SplendidFarzad commented 4 months ago

@sneha122 I already showed how I connect the source in the video log: https://internal.mobrog.com/pastebin/fba409c5-70f4-49b3-94de-13098ae370f7.avi

What do you think?

sneha122 commented 4 months ago

@SplendidFarzad Apologies, I had not checked the video since it was not opening on my end, checked the video now though. can you please try updating database name in datasource config from admin to splendid?

SplendidFarzad commented 4 months ago

@sneha122 It understandably gives authentication error as the authentication occurs on admin collection: msedge_IExgzyaJTn

The thing is, the structure and everything is fetchable in mongo shell and with other tools like Compass. What do you recommend?

sneha122 commented 4 months ago

@SplendidFarzad Makes sense, at this point I do not know what could be causing this issue as the same query in raw works completely fine. Let's get on a call to identify the issue? Here is my calendly link.

SplendidFarzad commented 4 months ago

@sneha122 I scheduled the appointment. But there is no meeting link in the appointment. Could you send me the meeting URL?

sneha122 commented 4 months ago

@SplendidFarzad I have updated the meeting link in the invite itself

sneha122 commented 4 months ago

Thank you so much @SplendidFarzad for reporting this issue, as we saw on the call the issue was because you had collections + views in your database and views is something that is causing issues when fetching collections, without views this structure is fetched correctly. Since you mentioned you would be deleting these views now that you have appsmith pages to replace it with, I am closing this issue resolution and creating a separate issue to track why views is messing up with structures.