Name disabled work item types in create and CSV import errors
What does this MR do and why?
Tells users when a work item type is disabled or archived, instead of saying it "could not be found or is not accessible".
On create, an explicitly requested type that is disabled or archived now gets " is disabled or archived for this project or group.". Unknown or inaccessible types keep the old message. Imported issues stay exempt.
The work items CSV import now reports such a row by type name in the HTML and text emails. Before, it said "not available, please check your license and permissions", which points at the wrong cause. Nothing is created when any row is unavailable, same as the other type errors.
This MR has no flag. Both changes only alter error messages on requests that were already rejected, so no request that succeeded before fails now.
Details
NamespacedType#disabled_or_archived? checks the enabled toggle and the archived state. It does not do the project/group context check that enabled? does, so group-only types such as Epic are not rejected in project context here. enabled? now calls disabled_or_archived?.
Issues::BuildService used to drop an unavailable type and add the generic "could not be found or is not accessible." error. It now keeps the type, reports it by name, and falls back to the default type as before.
WorkItemTypeVisibilityHelpers lets specs disable types for a namespace. The create path is covered through REST, GraphQL and quick actions.
For the CSV import, WorkItems::ImportCsvService gets an unavailable bucket in the preprocess type errors. It is filled from NamespacedType#disabled_or_archived?. It also covers a row that reaches the issue type through the fallback when the type column is missing.
The license and permission check runs before the disabled or archived check, the same order as Issues::BuildService. A type that is both disallowed and disabled, such as Epic in a project CSV when an ancestor group disabled Epic, is reported as disallowed. Re-enabling it would not make the row importable.
References
- Part of the split of !260607 (merged).
- No dependencies. Based on
master. - !260607 (merged) is stacked on this MR.
How to set up and validate locally
- In a project, disable the Issue or Task work item type in the work item settings.
- Create an issue through REST or GraphQL with that type set explicitly. The error names the type and says it is disabled or archived.
- Create one with a type that does not exist. The old "could not be found or is not accessible." message is still there.
- Import a work items CSV with a row that uses the disabled type. The completion email lists the type by name and says nothing was imported.
Test CSV
Run this on a local GDK with this branch checked out. In the project's work item settings, disable Issue and Incident and leave Task enabled. Then import from the work items list (Actions > Import > Import CSV):
title,description,type
CSV import check: enabled Task,This row uses an enabled type.,Task
CSV import check: disabled Issue,This row uses a disabled type.,Issue
CSV import check: disabled Incident,This row uses a disabled type.,IncidentNothing is imported, the Task row included, because the file has type errors.
Verified on a gdkbox (master, then master with this branch applied), with Issue and Incident disabled for the project. Text email before:
No work items have been imported.
Some values in the "type" column could not be matched with supported work item types:
Lines 3, 4: Work item type is not available. Please check your license and permissions.
Please fix the lines with errors and try the CSV import again.After:
No work items have been imported.
Some values in the "type" column could not be matched with supported work item types:
Line 3: Work item type "Issue" is disabled or archived for this project.
Line 4: Work item type "Incident" is disabled or archived for this project.
Please fix the lines with errors and try the CSV import again.To see the "Before" email on gitlab.com today, import the same file into gl-demo-ultimate-plan-stage/work-items with Task changed to Bug and Incident changed to Star. That project has Bug and Incident enabled, Issue disabled and Star archived. It will only show the "After" email once this MR is deployed.
Specs:
spec/models/work_items/types_framework/namespaced_type_spec.rbspec/services/issues/build_service_spec.rb- REST and GraphQL create specs:
ee/spec/requests/api/epics_spec.rb,ee/spec/requests/api/work_items/create_spec.rb,ee/spec/requests/api/graphql/mutations/epics/create_spec.rb,ee/spec/requests/api/graphql/mutations/work_items/create_spec.rb,ee/spec/requests/api/graphql/mutations/notes/create/note_spec.rb - CSV import:
spec/services/work_items/import_csv_service_spec.rb,ee/spec/services/ee/work_items/import_csv_service_spec.rb,spec/views/notify/import_work_items_csv_email.html.haml_spec.rb
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist.
Generated with Claude Code