Add custom error message in files UpdateService
## Problem We have refactored [edit blob to use rest API](https://gitlab.com/gitlab-org/gitlab/-/issues/509968). This allowed us to again show the custom error, [when the file has changed while editing](https://gitlab.com/gitlab-org/gitlab/-/blob/484b0d8e12eaa17d1a540266f035b6d3ca2df676/app/services/files/update_service.rb#L34): ```ruby if file_has_changed?(@file_path, @last_commit_sha) raise FileChangedError, _('You are attempting to update a file that has changed since you started editing it.') end ``` But previously we also had a custom message for when the fork and upstream project diverged. It was changed to a generic message (see https://gitlab.com/gitlab-org/gitlab/-/merge_requests/174287/diffs#069250b9207d28598a0d9930dc39952a10c386ab_56_64). But now that we're using `/api/:version/projects/:id/repository/files/:file_path`, we are getting `403 Forbidden` (see the screenshot below). ## Solution Add another custom error to `UpdateService` that returns: > Can't edit this file. The fork and upstream project have diverged. Edit the file on the fork It should be shown in the case described in this feature test: https://gitlab.com/gitlab-org/gitlab/-/blob/2c910bfc98a544cacc64489139abfad3f7f2e890/spec/features/projects/files/editing_a_file_spec.rb#L56 ## Context The following discussion from !202756 should be addressed: - [ ] @ms.mondrian started a [discussion](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/202756#note_2730817184): (+2 comments) > **suggestion:** can we update error message in `spec/features/projects/files/editing_a_file_spec.rb` to the more specific one like they were before? i updated them in https://gitlab.com/gitlab-org/gitlab/-/merge_requests/174287+ and this refactor should give us the ability to put this back. > > ![CleanShot_2025-09-04_at_12.57.42](/uploads/f45d0f6546bea3fd0f6c0b2bd71b1892/CleanShot_2025-09-04_at_12.57.42.png) - [ ] @psjakubowska > Good catch. I'm wondering why this hasn't failed in the pipeline. > > FYI the copy is slightly different now: > > > You are attempting to update a file that has changed since you started editing it. > > What I don't like is that for users without write access, it returns "403 Forbidden" > > ![Screenshot_2025-09-09_at_11.55.16](/uploads/d2f6e71ec316e4bddbd0fabb32155c65/Screenshot_2025-09-09_at_11.55.16.png) > > I think I'll map that on frontend to the current one "An error occurred editing the blob"
issue