Bug description

When using Gamma role: 1. Drill-detail data can be showed but alert: "There was an error loading the dataset metadata" 2. Drill-by alert "Failed to load dimensions for drill by" F12 log showed: xxxx:8088/api/v1/dataset/5 404 (NOT FOUND)

Permissions added to Gamma following: https://github.com/apache/superset/pull/27029

How to reproduce the bug

Create dashboard using admin role View dashboard using gamma role -> drill-by

Screenshots/recordings

No response

Superset version

4.0.2

Python version

3.11

Node version

16

Browser

Chrome

Additional context

No response

Checklist

  • [X] I have searched Superset docs and Slack and didn't find a solution to my problem.
  • [X] I have searched the GitHub issue tracker and didn't find a similar bug report.
  • [ ] I have checked Superset's logs for errors and if I found a relevant Python stacktrace, I included it here as text in the "additional context" section.

Comment From: dosubot[bot]

@LaurenceLong Hello there! 👋 I'm here to help you with any bugs, questions, or contributions you have for the project. I'm looking forward to working with you!

To resolve the "Failed to load dimensions for drill by" error when using the Gamma role in Apache Superset, ensure the following:

  1. Dataset Existence: Verify that the dataset with the specified datasetId exists in the database. You can check this by querying the database directly or using an API endpoint that lists available datasets.

  2. Permissions: Ensure that the Gamma role has the necessary permissions to access the dataset and the columns required for the drill-by functionality. This includes:

  3. Access to the dataset.
  4. Access to the columns required for the drill-by functionality.

  5. Correct Endpoint: Double-check the endpoint URL and ensure that the datasetId is correctly formatted and valid.

  6. Database Access: Verify that the database is accessible and that there are no connection issues. Ensure that the database is properly configured and running.

Here is a relevant code snippet that handles the loading of drill-by options and the error handling:

useEffect(() => {
    async function loadOptions() {
      const datasetId = Number(formData.datasource.split('__')[0]);
      try {
        setIsLoadingColumns(true);
        let response: JsonResponse;
        if (loadDrillByOptions) {
          response = await loadDrillByOptions(datasetId, formData);
        } else {
          response = await cachedSupersetGet({
            endpoint: `/api/v1/dataset/${datasetId}?q=${queryString}`,
          });
        }
        const { json } = response;
        const { result } = json;
        setDataset(result);
        setColumns(
          ensureIsArray(result.columns)
            .filter(column => column.groupby)
            .filter(
              column =>
                !ensureIsArray(
                  formData[drillByConfig?.groupbyFieldName ?? ''],
                ).includes(column.column_name) &&
                column.column_name !== formData.x_axis &&
                ensureIsArray(excludedColumns)?.every(
                  excludedCol => excludedCol.column_name !== column.column_name,
                ),
            ),
        );
      } catch (error) {
        logging.error(error);
        supersetGetCache.delete(`/api/v1/dataset/${datasetId}`);
        addDangerToast(t('Failed to load dimensions for drill by'));
      } finally {
        setIsLoadingColumns(false);
      }
    }
    if (handlesDimensionContextMenu && hasDrillBy) {
      loadOptions();
    }
  }, [
    addDangerToast,
    drillByConfig?.groupbyFieldName,
    excludedColumns,
    formData,
    handlesDimensionContextMenu,
    hasDrillBy,
  ]);

By ensuring the dataset exists, the Gamma role has the necessary permissions, the endpoint is correct, and the database is accessible, you can mitigate the occurrence of the 404 error and the "Failed to load dimensions for drill by" alert [1][2].

To continue talking to Dosu, mention @dosu.

Comment From: LaurenceLong

I just add all_datasource_access to Gamma role and it works. But I think get columns from datasource/samples api may be a better way.

Comment From: sfirke

I can validate: I added can_explore and can_write_ExploreFormDataRestAPI to my Gamma role, and like you said my user was able to see the data but it was accompanied by an error message "There was an error loading the dataset metadata." Like you, I added that all_datasource_access permission and the error went away - but that seems possibly overkill.

Comment From: rusackas

Is this still an issue in 4.1.2 or newer? This has been untouched for almost a year iand may be closed as inactive/not-planned soon.

Comment From: rusackas

Closing as inactive / not-planned