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 not showing all datasets available #28638

Open
3 tasks done
hanslemm opened this issue May 22, 2024 · 1 comment
Open
3 tasks done

🐛 RLS form not showing all datasets available #28638

hanslemm opened this issue May 22, 2024 · 1 comment
Labels
authentication:row-level-security Related to Row Level Security

Comments

@hanslemm
Copy link
Contributor

hanslemm commented May 22, 2024

Bug description

When trying to create a new RLS rule, in the rule pop-up (check image for reference), there is the drop-down field for datasets. If you start filling this pop-up through the dataset field (which would be natural since this the obligatory field), in my version of Superset (and since 3.0.0 tbh I already detected this), not all datasets registered in Superset are available in the drop-down menu.
Yet, if you rather start filling this pop-up through the role drop-down, then all the datasets will be visible.
image

How to reproduce the bug

Preconditions: have RBAC enabled in your Superset config.

  1. Create a new dataset.
  2. Go to RLS and press the + button to create a new rule.
  3. In the new pop-up, there will be the dataset drop-down. Click it, and the new dataset will be missing.
    3.1. If you set the role drop-down first, then all datasets will be available to the dataset drop-down.

Screenshots/recordings

No response

Superset version

4.0.1

Python version

3.10

Node version

I don't know

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 May 22, 2024

To resolve the issue where the dataset drop-down in the RLS rule creation pop-up in Superset does not show all available datasets unless a role is selected first, ensure that the AsyncSelect component for datasets is properly configured to load options independently of the role selection.

Check the loadTableOptions function to ensure it correctly fetches the dataset options:

const loadTableOptions = useMemo(
  () =>
    (input = '', page: number, pageSize: number) => {
      const query = rison.encode({
        filter: input,
        page,
        page_size: pageSize,
      });
      return SupersetClient.get({
        endpoint: `/api/v1/rowlevelsecurity/related/tables?q=${query}`,
      }).then(response => {
        const list = response.json.result.map(
          (item: { value: number; text: string }) => ({
            label: item.text,
            value: item.value,
          }),
        );
        return { data: list, totalCount: response.json.count };
      });
    },
  [],
);

<AsyncSelect
  ariaLabel={t('Tables')}
  mode="multiple"
  onChange={onTablesChange}
  value={(currentRule?.tables as SelectValue[]) || []}
  options={loadTableOptions}
/>

Ensure that loadTableOptions is fetching and returning the dataset options independently of the role selection.

Additionally, verify that the RowLevelSecurityModal component is correctly set up to fetch related tables and roles independently. The endpoints for fetching related tables and roles should be correctly implemented and tested:

const getRelatedTablesEndpoint =
  'glob:*/api/v1/rowlevelsecurity/related/tables?q*';
const getRelatedRolesEndpoint =
  'glob:*/api/v1/rowlevelsecurity/related/roles?q*';

fetchMock.get(getRelatedTablesEndpoint, mockGetTablesResult);
fetchMock.get(getRelatedRolesEndpoint, mockGetRolesResult);

User permissions or RBAC configurations might also influence the visibility of datasets. Ensure that the API endpoints respect the user's permissions and roles.

Recent changes in the superset-frontend repository might also affect the behavior of the dataset drop-down. Relevant pull requests include:

  1. #20449 - Fix: RLS new db migration downgrade fails on SQLite.
  2. #20432 - Feat: add name, description, and non-null tables to RLS.
  3. #22325 - Feat(RLS): RESTful APIs and react view for RLS.
  4. #22818 - Fix: revert RESTful APIs and react view for RLS.
  5. #25400 - Fix: Info Tooltip + Button Alignment on RLS Modal.

These updates might impact the dataset drop-down behavior in the RLS rule creation pop-up.

Details

Sources


About Dosu
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

To continue the conversation, mention @dosu.

@dosubot dosubot bot added the authentication:row-level-security Related to Row Level Security label May 22, 2024
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