Add work_item_type_names filter to Work Items REST API
What does this MR do and why?
Add a work_item_type_names array param to the Work Items REST API list endpoint so clients can filter by work item type NAME (including custom types), rather than only by integer type id.
Changes
- Finder (
app/finders/issues/issue_types_filter.rb): Addby_work_item_type_namesmethod wired into#filter. Resolves names case-insensitively viaWorkItems::TypesFramework::Provider.new(parent)in a single pass. Unknown names yield an empty result set. - Negation (
app/finders/issues_finder.rb): Addby_negated_work_item_type_namesalongside the existingby_negated_work_item_type_ids, resolving names the same way and feedingwithout_work_item_type_ids. - REST exposure (
lib/api/helpers/work_items/list_params.rb): Declarework_item_type_names(Array[String]) in both the top-level filter block and thenotblock. The param passes throughWorkItemsFilterParams#transformunchanged (no renaming needed). - EE finder specs (
ee/spec/finders/issues_finder_spec.rb): Coverwork_item_type_namesand the negated variant usingcreate(:work_item_custom_type, namespace: root_namespace); assert a custom-type name resolves and filters correctly. - REST shared examples (
spec/support/shared_examples/api/work_items_filter_shared_examples.rb): Addwork_item_type_namescontexts covering both case-insensitive matching and negation.
Database review
No migrations, no schema changes, no new columns or indexes.
This MR adds a work_item_type_names filter to the Work Items REST list finder.
Type names are resolved to work_item_type_id (in-memory, via WorkItems::TypesFramework::Provider#resolve_all no extra query), and the resolved ids reuse the existing Issue.with_work_item_type_ids / without_work_item_type_ids scopes.
The generated predicate is therefore identical to the already-merged work_item_type_ids filter (#605894); this
change adds no new query shape.
Raw SQL
Positive filter — work_item_type_names[]=Task&work_item_type_names[]=Bug
(names resolved to ids IN (5, 8); a single name collapses to = 5):
SELECT "issues".*
FROM "issues"
INNER JOIN "projects" ON "projects"."id" = "issues"."project_id"
LEFT JOIN project_features ON projects.id = project_features.project_id
WHERE (
EXISTS (
SELECT 1 FROM "project_authorizations"
WHERE "project_authorizations"."user_id" = :user_id
AND project_authorizations.project_id = projects.id
)
OR projects.visibility_level IN (0, 10, 20)
)
AND ("project_features"."issues_access_level" > 0 OR "project_features"."issues_access_level" IS NULL)
AND "issues"."work_item_type_id" IN (5, 8)
ORDER BY "issues"."id" DESC
LIMIT 20;Negated filter — not[work_item_type_names][]=Task (NOT IN / !=):
... AND "issues"."work_item_type_id" NOT IN (5)
ORDER BY "issues"."id" DESC
LIMIT 20;Acceptance criteria
GET /projects/:id/-/work_items?work_item_type_names[]=Bugreturns only type "Bug" work items, including namespace-defined custom types.- Case-insensitive:
work_item_type_names[]=bugmatches type "Bug". - Multiple names OR together:
work_item_type_names[]=Bug&work_item_type_names[]=Incidentreturns both. not[work_item_type_names][]=Bugexcludes type "Bug".- Unknown type name matches nothing (no error); all-unknown yields an empty result set.
- Works on both project and group list endpoints.
References
Closes #605891 (closed)
Screenshots or screen recordings
| Screenshot | |
|---|---|
| No type filter | ![]() |
| Filter by type name | ![]() |
Mutually exclusive with work_item_type_ids |
![]() |
N/A — REST API change only.
How to set up and validate locally
- Start a local GitLab instance.
- Create a project with work items of different types (e.g., Task, Issue).
- Call the API:
GET /api/v4/projects/:id/work_items?work_item_type_names[]=Task - Verify only Task work items are returned.
- Test case-insensitivity:
work_item_type_names[]=taskshould also return Tasks. - Test negation:
not[work_item_type_names][]=Taskshould exclude Tasks.
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.


