mistercrunch opened a new pull request, #34192:
URL: https://github.com/apache/superset/pull/34192
## Summary
This PR fixes an issue where the filter parameter in the Row Level
Security (RLS) related tables endpoint
(`/api/v1/rowlevelsecurity/related/tables`) was not being applied. When
users tried to search for specific tables
in the RLS CRUD UI, all tables were returned regardless of the filter
value.
## Problem
The
`/api/v1/rowlevelsecurity/related/tables?q=(filter:mult,page:1,page_size:100)`
endpoint was ignoring the
`filter` parameter because:
- The RLS API was missing the proper filter configuration for the `tables`
field
- Without this configuration, the `_get_related_filter` method in the base
API didn't know which field to filter on
## Solution
1. **Created a new filter class** `FilterRelatedTables` in
`superset/views/filters.py` that:
- Performs case-insensitive substring matching using SQLAlchemy's
`ilike` with wildcards
- Filters tables by their `table_name` field - Follows the same pattern
as other "contains" filters in the codebase (e.g., `FilterRelatedOwners`,
`DashboardTitleOrSlugFilter`)
2. **Updated the RLS API configuration** to use this filter: ```python
related_field_filters = { "tables": RelatedFieldFilter("table_name",
FilterRelatedTables), "changed_by": RelatedFieldFilter("first_name",
FilterRelatedOwners), }
Testing
Added a new test test_rls_tables_related_api_with_filter that verifies:
- Filtering with a matching substring returns only tables containing that
substring
- Filtering with a non-existent substring returns no results
- The filter is case-insensitive
Changes
- superset/views/filters.py: Added FilterRelatedTables class
- superset/row_level_security/api.py: Added filter configuration for
tables field
- tests/integration_tests/security/row_level_security_tests.py: Added test
for filter functionality
Impact
This fix improves the user experience in the RLS CRUD interface by
allowing users to efficiently search and filter
tables when creating or editing row-level security rules.
<!---
Please write the PR title following the conventions at
https://www.conventionalcommits.org/en/v1.0.0/
Example:
fix(dashboard): load charts correctly
-->
### SUMMARY
<!--- Describe the change below, including rationale and design decisions -->
### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
<!--- Skip this if not applicable -->
### TESTING INSTRUCTIONS
<!--- Required! What steps can be taken to manually verify the changes? -->
### ADDITIONAL INFORMATION
<!--- Check any relevant boxes with "x" -->
<!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue -->
- [ ] Has associated issue:
- [ ] Required feature flags:
- [ ] Changes UI
- [ ] Includes DB Migration (follow approval process in
[SIP-59](https://github.com/apache/superset/issues/13351))
- [ ] Migration is atomic, supports rollback & is backwards-compatible
- [ ] Confirm DB migration upgrade and downgrade tested
- [ ] Runtime estimates and downtime expectations provided
- [ ] Introduces new feature or API
- [ ] Removes existing feature or API
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]