Remove the group policy store REST client and axios error fallback

What does this MR do and why?

Summary

This change unifies how security policies are created, updated, and deleted for both groups and organizations — previously, groups used a separate REST API while organizations used GraphQL. Now, both use the same GraphQL mutations, with the only difference being which "container" identifier is passed (a group path for groups, an organization ID for organizations).

A safety guard was added to prevent callers from accidentally passing a container identifier as a regular parameter, which could cause conflicts. The error handling was also simplified since there's no longer a REST API path to account for. Tests were updated to reflect the new unified behavior.

References

Related to https://gitlab.com/gitlab-org/gitlab/-/work_items/630066

Screenshots or screen recordings

No UI change.

How to set up and validate locally

  1. Check out this branch.
  2. Run grep -n PolicyStore ee/app/assets/javascripts/api.js and expect no output.
  3. Run grep -rn response.data ee/app/assets/javascripts/policy_store ee/spec/frontend/policy_store and expect no output.
  4. Run yarn jest ee/spec/frontend/policy_store ee/spec/frontend/api_spec.js and expect all green.
  5. Optionally, with the security_policies_v2 flag enabled, create, update, and delete a group policy at /groups/<group-path>/-/security/policy_store and confirm the network tab shows only GraphQL requests.

Locally: jest ee/spec/frontend/policy_store ee/spec/frontend/api_spec.js passed 33 suites, 656 tests. eslint and prettier clean.

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.

Plan, verification and review

This MR removes dead code left over after the GraphQL migration; no behavior change is intended.

Pre-review verdict on this diff: pass with findings. Nothing blocking; no code changed as a result. Each finding is recorded here rather than silently resolved.

Findings and how each was handled
  1. Merge order. This MR targets the branch of !258168 (merged). On master the three policies.js group branches still call the removed helpers, so retargeting to master before 258168 merges would break every group write. The target branch is the guard; do not retarget early.
  2. Falsy GraphQL message. apiErrorMessage now returns graphQLErrors[0].message as is, where the old code fell through to the REST branch for a falsy value. Every caller already falls back on any falsy result, so behaviour is unchanged.
  3. String type guard gone. The removed typeof reason === 'string' filter only guarded the REST branch. The GraphQL branch was never guarded, and the GraphQL spec requires errors[].message to be a string. Left as is.
  4. Grape-shaped body not pinned. The replacement spec row covers response.data.message; response.data.error traverses the same expression. Not added.
  5. Detail spec reshape matches what deletePolicy actually throws; organization-context coverage is untouched.
  6. No orphaned imports in api.js; repo-wide grep finds no reference to the seven removed members or to error.response.data under the policy store.
  7. Backend REST API in ee/lib/api/govern/policies.rb is deliberately untouched; it is a documented experiment API.
  8. Knowledge base entries describing the REST stopgap are updated in the team knowledge repo, not here.
  9. Two stale comments still mention REST (policies.js near toListPolicies, list/app.vue). Pre-existing on master and outside this MR's scope; left for a separate pass.
Gate output
jest ee/spec/frontend/policy_store ee/spec/frontend/api_spec.js → Test Suites: 33 passed · Tests: 656 passed
grep -n PolicyStore ee/app/assets/javascripts/api.js                → (empty)
grep -rn response.data under policy_store app + spec dirs           → (empty)
eslint + prettier on the four changed files                         → clean
Integrity: five utils_spec examples removed, all asserting the removed axios branch;
           one detail spec example reshaped to PolicyStoreMutationError; no skips, no .only
Edited by Artur Fedorov

Merge request reports

Loading
Loading