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

RLS form does not show all available datasets when searching by mask #29707

Open
2 of 3 tasks
calvad0s opened this issue Jul 26, 2024 · 1 comment
Open
2 of 3 tasks

RLS form does not show all available datasets when searching by mask #29707

calvad0s opened this issue Jul 26, 2024 · 1 comment
Labels
authentication:row-level-security Related to Row Level Security

Comments

@calvad0s
Copy link

Bug description

When trying to create a new RLS rule, in the rule pop-up there is the drop-down field for datasets.
If you start filling this field with a search value, the results will display in the drop-down menu with incomplete list of all available values.

An example of this behavior can be seen with the public dashboard "USA Births Names". Two datasets are used: birth_names and birth_france_by_region.
Try to find this datasets in the Datasets section:
image

Try to add new rule:
image

If, when creating a new RLS rule, at first place the cursor in the datasets field and scroll all available values ​​from the drop-down list all the way down (without filling out the search field). And then fill out the dataset search form again, all available datasets ​​will be displayed:
image

How to reproduce the bug

Preconditions: have RBAC enabled in your Superset config.

  1. Install example dashboards (in this example "USA Births Names")
  2. Go to Datasets section and make sure that the datasets exists: birth_names, birth_france_by_region.
  3. Go to RLS and press the + button to create a new rule.
  4. In the new pop-up, there will be the dataset drop-down. Click it, and enter "birth". Make sure the pop-up list is empty
  5. Now place the cursor in the datasets field and scroll pop-up list all the way down. Make sure birth_names and birth_france_by_region datasets available.
  6. Now enter again "birth" in the dataset search box. Birth_names and birth_france_by_region datasets will be available to the dataset drop-down.

Screenshots/recordings

No response

Superset version

master / latest-dev

Python version

3.9

Node version

16

Browser

Chrome

Additional context

Superset version 4.0.1

Note: The dashboard will be successfully found if you enter its ID in the search field
image

This does not work when searching in the Dashboards section.

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.
@dosubot dosubot bot added the authentication:row-level-security Related to Row Level Security label Jul 26, 2024
Copy link

dosubot bot commented Jul 26, 2024

@calvad0s Hello! I'm here to help you with your Superset issues. I can assist with bug-solving, answer questions, and guide you on becoming a contributor.

To resolve the issue where the dataset drop-down in the RLS rule creation pop-up in Superset does not show all available datasets when a search value is entered, ensure that the AsyncSelect component's loadOptions function is correctly fetching and filtering the datasets based on the search input.

Here is the relevant part of the code that handles the dataset fetching and filtering:

const loadDatasetOptions = async (
    search: string,
    page: number,
    pageSize: number,
  ) => {
    const query = rison.encode({
      columns: ['id', 'table_name', 'database.database_name', 'schema'],
      filters: [{ col: 'table_name', opr: 'ct', value: search }],
      page,
      page_size: pageSize,
      order_column: 'table_name',
      order_direction: 'asc',
    });
    return cachedSupersetGet({
      endpoint: `/api/v1/dataset/?q=${query}`,
    })
      .then((response: JsonResponse) => {
        const list: {
          customLabel: ReactNode;
          label: string;
          value: string | number;
        }[] = response.json.result.map((item: Dataset) => ({
          customLabel: DatasetSelectLabel(item),
          label: item.table_name,
          value: item.id,
        }));
        return {
          data: list,
          totalCount: response.json.count,
        };
      })
      .catch(async error => {
        const errorMessage = getErrorMessage(await getClientErrorObject(error));
        throw new Error(errorMessage);
      });
  };

Ensure that the AsyncSelect component is configured to use these functions:

<AsyncSelect
  ariaLabel={t('Dataset')}
  value={value}
  options={loadDatasetOptions}
  onChange={onChange}
  notFoundContent={t('No compatible datasets found')}
  placeholder={t('Select a dataset')}
/>

This setup ensures that the datasets are fetched and filtered based on the search input, and the results are displayed in the drop-down field [1][2].

To continue talking to Dosu, mention @dosu.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
authentication:row-level-security Related to Row Level Security
Projects
None yet
Development

No branches or pull requests

1 participant