Declare the permission of the saved view filter warning type
What does this MR do and why?
WorkItemSavedViewFilterWarningType has no granular token directive, so a fine-grained token fails when a saved view has a filter warning:
Cannot return null for non-nullable element of type 'WorkItemSavedViewFilterWarningType' for WorkItemSavedViewType.filterWarningsThis MR adds authorize_granular_token parent_authorizes: :read_work_item to the type and removes it from authorization_todo.txt. filterWarnings now checks read_work_item on the saved view's group or project. This is the same approach as !268628 (merged).
Why read_work_item and not read_work_item_saved_view
gitlab:permissions:validate needs a parent_authorizes: permission to be an ability on ProjectPolicy and GroupPolicy. read_work_item_saved_view is only on SavedViewPolicy, so the validator rejects it:
Field: WorkItemSavedViewType.filterWarnings
Permission: read_work_item_saved_view on projectread_work_item is on both policies. So a token with read_work_item_saved_view but no read_work_item gets filterWarnings: null and no error. The saved view still comes back.
Can we live with this, or should we add read_work_item_saved_view to the project and group policies in a follow-up? That is a policy change, so I kept it out of this MR.
The MCP saved view tools select filterWarnings (!265188, !265189), so they need this for fine-grained tokens.
References
Screenshots or screen recordings
No UI change.
Backend proof
Request spec spec/requests/api/graphql/namespace/saved_views_spec.rb covers group and project saved views:
- token with
read_namespace,read_work_item_saved_view,read_work_item: warnings come back, no errors - token without
read_work_item: saved view comes back,filterWarningsisnull, no errors
Without the type change, 4 of the 6 new examples fail with the error above. With it, all pass.
$ bin/rails runner '...ValidateTask.new.run'
GraphQL permissions are validNo database or query changes, so no query plans.
How to set up and validate locally
-
Give a group saved view a missing author, in
gdk rails c:WorkItems::SavedViews::SavedView.find(<id>).update!(filter_data: { author_ids: [0] }) -
Create a fine-grained token on the group with
read_namespace,read_work_item_saved_viewandread_work_item. -
Run this query with the token:
query { namespace(fullPath: "<group path>") { savedViews(id: "gid://gitlab/WorkItems::SavedViews::SavedView/<id>") { nodes { name filterWarnings { field message } } } } }On
masteryou get the "Cannot return null" error. On this branch you get the warning.
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.