feat(security_categories): return what DestroySecurityCategory deleted

What does this MR do?

securityCategoryDestroy answers with deletedCategoryGid and deletedAttributesGid: deleting a category deletes every security attribute under it, and the payload says which ones. DestroySecurityCategory selects only errors, so a caller cannot tell which of the attribute IDs it holds are gone.

This adds DestroySecurityCategoryWithResult, which selects both fields and returns them as numeric IDs in SecurityCategoryDestroyResult. DeletedAttributeIDs is an empty slice, not nil, when the category had no attribute. DestroySecurityCategory keeps its signature and now calls it. The mock is regenerated.

I found this while working on gitlab-mcp-server, which reports the attributes a category delete took with it.

Is this a breaking change?

Not for callers. DestroySecurityCategory keeps its signature and returns the same errors as before, and both fields have been in the payload since GitLab added the mutation, so the larger selection works on every version that has it. SecurityCategoriesServiceInterface gains a method, so a type outside client-go that implements the interface by hand needs it too; testing.MockSecurityCategoriesServiceInterface has it.

How was this tested?

  • TestSecurityCategoriesService_DestroySecurityCategoryWithResult checks that the document selects both fields and that the category ID and two attribute IDs come back. _noAttributes checks the empty slice, and _errors and _graphQLErrors check that the payload's errors and a top-level error return the error and no result.
  • On the code of main, with the new method standing in as a call of the old one, the two result tests fail and the two error tests pass. Six one-line mutants of the change each fail the new tests.
  • I checked the fields against Mutations::Security::Categories::Destroy and Security::Categories::DestroyService on GitLab master: the service lists the category's attributes that were not deleted before, so a category without attributes answers an empty list.
  • make generate and make fmt leave no drift, golangci-lint 2.15.0 reports 0 issues, buf format and buf lint pass, and go test work -race passes on Go 1.26 and 1.27.

This contribution was developed with AI assistance (Claude Code). I reviewed, tested and own every change.

Edited by José M. Requena Plens

Merge request reports

Loading
Loading