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
- Stacked on: !258168 (merged)
- Introduced the REST helpers removed here: !255586 (merged)
- Added backend groupPath to the mutations: !256765 (merged)
- Approved plan and progress: https://gitlab.com/gitlab-org/gitlab/-/work_items/630066#note_3916531280
Screenshots or screen recordings
No UI change.
How to set up and validate locally
- Check out this branch.
- Run
grep -n PolicyStore ee/app/assets/javascripts/api.jsand expect no output. - Run
grep -rn response.data ee/app/assets/javascripts/policy_store ee/spec/frontend/policy_storeand expect no output. - Run
yarn jest ee/spec/frontend/policy_store ee/spec/frontend/api_spec.jsand expect all green. - Optionally, with the
security_policies_v2flag enabled, create, update, and delete a group policy at/groups/<group-path>/-/security/policy_storeand 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
- Merge order. This MR targets the branch of !258168 (merged). On
masterthe threepolicies.jsgroup branches still call the removed helpers, so retargeting tomasterbefore 258168 merges would break every group write. The target branch is the guard; do not retarget early. - Falsy GraphQL message.
apiErrorMessagenow returnsgraphQLErrors[0].messageas 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. - 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 requireserrors[].messageto be a string. Left as is. - Grape-shaped body not pinned. The replacement spec row covers
response.data.message;response.data.errortraverses the same expression. Not added. - Detail spec reshape matches what
deletePolicyactually throws; organization-context coverage is untouched. - No orphaned imports in
api.js; repo-wide grep finds no reference to the seven removed members or toerror.response.dataunder the policy store. - Backend REST API in
ee/lib/api/govern/policies.rbis deliberately untouched; it is a documented experiment API. - Knowledge base entries describing the REST stopgap are updated in the team knowledge repo, not here.
- Two stale comments still mention REST (
policies.jsneartoListPolicies,list/app.vue). Pre-existing onmasterand 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