I am getting the error "Error loading data for this chart " when embedding one of my charts. The chart data loads fine when viewing it through mongodb Atlas dashboards. Is it possible to get more details as to why the data cannot be retrieved when embedding?
I am using the charts-embed-dom SDK and i am running an aggregation to filter the data before showing it in the chart. The chart IDs are as follows:
The same aggregation is also being used in a similar chart (638e4505-6b6e-491c-8f53-43649d83c00f) but the data is loading, which is why i was curious to see the errors as the other charts were also loading fine up till a few days ago.
My guess was that the only difference between them is the one that’s loading has to filter a lot less records, but there’s no way for me to confirm this as when loading through the charts dashboard itself, everything loads fine.
Oh right, sorry I forgot to check the dashboard settings. Is it possible to briefly enable unauthenticated embedding and see if that renders without the token? If so that would imply that issue is to do with the token verification (or if not it will give other clues).
That’s really strange. The aggregation stage is valid, and I just tested it on one of my embedded charts and it works fine. Can you email me at tom.hollander @ mongodb.com so we can troubleshoot further?
Just to close off the loop here. As discussed offline, in this particular case, the authenticated embedding uses App Service as authentication provider with the “Fetch data using Atlas App Services” enabled. When rules configured in App Services, it will only support aggregation stages/expressions supported by MongoDB 4.4 for user functions. $dateSubtract is an aggregation expression that has been added with MongoDB 5.0, hence the App Service raised an error which causes the “Cannot retrieve data” error in Charts.
Until the 5.0 aggregation expression is supported, the workaround for this issue is to disable the “Fetch data using Atlas App Services” option from the authentication provider setting.