Skip to content

Prevent redirecting to snippet view on error

Denys Mishunov requested to merge 217727-snippet-update-error into master

What does this MR do?

Currently, in snippets, the GraphQL mutations for creating/updating snippet can fail in two ways:

  • with a server error (like 500, for example)
  • with the errors object in, otherwise, seemingly successful response

In both cases, we should stay on the same form and show the error message.

The first case is properly handled with catching the errors.

This MR addresses the second scenario when mutation is returned as successful but contains errors Array with the more detailed/granular error messages. Right now, this scenario is broken: the browser gets reloaded losing any changes to the existing snippet.

Click-testing steps

  1. Enable :snippets_edit_vue feature flag in Rails console
  2. Go to any existing snippet. Click "Edit"
  3. On the edit form for the snippet, type in the illegal File path for the snippet (invalid://file/path for example)
  4. Click save
  5. The browser will be redirected to the snippet's view without saving the updated data

Does this MR meet the acceptance criteria?

Since this feature is still behind the feature flag, no Changelog entry has been provided.

Conformity

References #217727 (closed)

Edited by 🤖 GitLab Bot 🤖

Merge request reports