Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drill-by alert "Failed to load dimensions for drill by" using Gamma role #30233

Open
2 of 3 tasks
LaurenceLong opened this issue Sep 11, 2024 · 2 comments
Open
2 of 3 tasks

Comments

@LaurenceLong
Copy link

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: #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

  • I have searched Superset docs and Slack and didn't find a solution to my problem.
  • 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.
Copy link

dosubot bot commented Sep 11, 2024

@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:

    • Access to the dataset.
    • Access to the columns required for the drill-by functionality.
  3. Correct Endpoint: Double-check the endpoint URL and ensure that the datasetId is correctly formatted and valid.

  4. 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.

@LaurenceLong
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant