GitHub user dosubot[bot] added a comment to the discussion: Restrict charts
<!-- Answer -->
Your custom filter will only be enforced if it's registered in the
ChartRestApi's base_filters in superset/charts/api.py. If you add it only to
search_filters, it won't run unless the frontend explicitly requests it. Make
sure your base_filters looks like this (replacing ChartFilter with your filter):
```python
base_filters = [
["id", ChartOwnedByMeOrUsersFilter, lambda: []],
]
```
Also, confirm that you restarted the Superset server after making code
changes—otherwise, the new filter won't be picked up. If the filter is
correctly registered and the server is restarted, it will be applied to all
/api/v1/chart/ queries, including those from the UI. If you still see other
users' charts, double-check that your filter's apply() method is being called
and that your filter logic is correct.
If you want to test independently of the UI, try hitting the /api/v1/chart/
endpoint directly (e.g., with curl or Postman) and see if the results are
filtered as expected. If not, the filter is not being applied globally—most
likely due to registration or server restart issues. For more details, see the
[ChartRestApi
implementation](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset/charts/api.py#L107-L1155).
Let me know if you want to share your filter and registration code for a quick
review!
<!-- Dosu Comment Footer -->
*To reply, just mention [@dosu](https://go.dosu.dev/dosubot).*
---
<sup>How did I do?
[Good](https://app.dosu.dev/response-feedback/fc145fea-2884-4aac-a108-fc4df74cdadc?feedback_type=great_response)
|
[Irrelevant](https://app.dosu.dev/response-feedback/fc145fea-2884-4aac-a108-fc4df74cdadc?feedback_type=irrelevant_answer)
|
[Incorrect](https://app.dosu.dev/response-feedback/fc145fea-2884-4aac-a108-fc4df74cdadc?feedback_type=incorrect_sources)
|
[Verbose](https://app.dosu.dev/response-feedback/fc145fea-2884-4aac-a108-fc4df74cdadc?feedback_type=too_verbose)
|
[Hallucination](https://app.dosu.dev/response-feedback/fc145fea-2884-4aac-a108-fc4df74cdadc?feedback_type=hallucination)
| [Report
🐛](https://app.dosu.dev/response-feedback/fc145fea-2884-4aac-a108-fc4df74cdadc?feedback_type=bug_report)
|
[Other](https://app.dosu.dev/response-feedback/fc145fea-2884-4aac-a108-fc4df74cdadc?feedback_type=other)</sup>
[](https://app.dosu.dev/a28d3c7e-a9d3-459e-9fb6-3a6f9ff4f357/ask?utm_source=github) [](https://cursor.com/link/prompt?text=Your%20custom%20filter%20will%20only%20be%20enforced%20if%20it%27s%20registered%20in%20the%20ChartRestApi%27s%20base_filters%20in%20superset/charts/api.py.%20If%20you%20add%20it%20only%20to%20search_filters%2C%20it%20won%27t%20run%20unless%20the%20frontend%20explicitly%20requests%20it.%20Make%20sure%20your%20base_filters%20looks%20like%20this%20%28replacing%20ChartFilter%20with%20your%20filter%29%3A%0A%0A%60%60%60python%0Abase_filters%20%3D%20%5B%0A%20%20%20%20%5B%22id%22%2C%20ChartOwnedByMeOrUsersFilter%2C%20lambda%3A%20%5B%5D%5D%2C%0A%5D%0A%60%60%60%0A%0AAlso%2C%20confirm%20that%20you%20restarted%20the%20Superset%20server%20after%20making%20code%20changes%E2%80%94otherwise%2C%20the%20new%20filter%20won%27t%20be%20picked%20up.%20If%20the%20filter%20i
s%20correctly%20registered%20and%20the%20server%20is%20restarted%2C%20it%20will%20be%20applied%20to%20all%20/api/v1/chart/%20queries%2C%20including%20those%20from%20the%20UI.%20If%20you%20still%20see%20other%20users%27%20charts%2C%20double-check%20that%20your%20filter%27s%20apply%28%29%20method%20is%20being%20called%20and%20that%20your%20filter%20logic%20is%20correct.%0A%0AIf%20you%20want%20to%20test%20independently%20of%20the%20UI%2C%20try%20hitting%20the%20/api/v1/chart/%20endpoint%20directly%20%28e.g.%2C%20with%20curl%20or%20Postman%29%20and%20see%20if%20the%20results%20are%20filtered%20as%20expected.%20If%20not%2C%20the%20filter%20is%20not%20being%20applied%20globally%E2%80%94most%20likely%20due%20to%20registration%20or%20server%20restart%20issues.%20For%20more%20details%2C%20see%20the%20%5BChartRestApi%20implementation%5D%28https%3A//github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset/charts/api.py%23L107-L1155%29.%0A%0ALet%20me%20know%20if%20you%2
0want%20to%20share%20your%20filter%20and%20registration%20code%20for%20a%20quick%20review%21) [](https://go.dosu.dev/discord-bot) [](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/apache/superset/discussions/36259)
GitHub link:
https://github.com/apache/superset/discussions/36259#discussioncomment-15083233
----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]