Return the errors payload from environment local mutations
What does this MR do and why?
The Environments page uses Apollo Client local resolvers for some actions. Three local mutation resolvers in app/assets/javascripts/environments/graphql/resolvers/base.js did not return their result to the caller:
stopEnvironmentRESTdeleteEnvironmentrollbackEnvironment
Each mutation document selects an errors field, so Apollo expects an object with errors. Each resolver chained two .then calls after the HTTP request. The first .then built the payload with buildErrors(). The second .then evicted the folder field from the cache and did not return the payload. As a result:
stopEnvironmentRESTandrollbackEnvironmentresolved toundefined.deleteEnvironmentresolved totrue, the return value ofcache.evict.- Apollo logged
Missing field 'errors' while writing result truein the browser console. - The delete and rollback modals read
errorsfrom the result, so they never received the payload.
This affects anyone who stops, deletes, or rolls back an environment from an environment folder page. The visible symptom is a console error. The list still refreshes.
What changes
- Each of the three resolvers now evicts the cache inside the first
.thenand returnsbuildErrors()from it. - The second
.thenis removed. - The
.catchbranches are unchanged. They already returnbuildErrors([...])with a message. spec/frontend/environments/graphql/resolvers/base_spec.jsnow asserts the resolved value of each resolver equals{ errors: [], __typename: 'LocalEnvironmentErrors' }.
Approach
- Ruled out: remove the
errorsselection from the mutation documents. The delete and rollback modals depend on the payload for the failure path, and the.catchbranches already return it. - The success path keeps the same behavior. The cache eviction still runs before the promise resolves. Only the resolved value changes.
Screenshots or screen recordings
The page looks the same before and after. The difference is in the browser console. A temporary feature spec deleted a stopped environment from the folder page and collected the SEVERE browser logs.
| Before | After |
|---|---|
![]() |
![]() |
| Run | Missing field 'errors' while writing result true in the console |
|---|---|
| Before, master without this change | 1 |
| After, with this change | 0 |
Other SEVERE entries in both runs are unrelated GDK noise. Examples are Snowplow connection errors and a toJSON Vue warning.
How to set up and validate locally
- Run
yarn jest spec/frontend/environments/graphql/resolvers/base_spec.js. It passes in the Vue 2 lane and withVUE_VERSION=3. - In GDK, open a project and go to Operate > Environments.
- Open an environment folder and open the browser console.
- Stop an environment, then delete it from the Stopped tab.
- On master, the console shows
Missing field 'errors' while writing result trueafter the delete. On this branch, the console stays clean and the list refreshes.
MR acceptance checklist
This MR was evaluated against the acceptance checklist.
References
- Part of section D of #628901 (console errors in feature specs)
- Console check and baseline allowlist MR that surfaced it: !255207 (closed)
- Reveal pipeline job showing the error: https://gitlab.com/gitlab-org/gitlab/-/jobs/16462296271

