Fix confusing error message for expected_old_oid mismatches in UserCommitFiles
Problem
This MR aims to solve the issue #6292
When using expected_old_oid
with a SHA that exists in the repository but isn't the current branch tip, UserCommitFiles returns an unhelpful error message: GRPC::FailedPrecondition: 9:reference update: exit status 128
.
This gives users no context about what went wrong, which reference failed, or what the actual vs expected values were.
So I added structured error handling for reference update failures in UserCommitFiles following the same pattern already implemented in UserDeleteBranch and UserMergeBranch.
When a reference update fails, the error now includes:
- Which reference failed to update
- The expected old object ID
- The new object ID that was being set
Changes
-
proto/operations.proto: Added
ReferenceUpdateError reference_update = 4
toUserCommitFilesError
-
internal/gitaly/service/operations/commit_files.go: Replaced generic error handling with structured
ReferenceUpdateError
details
Edited by Siddharth Asthana