pub fn map_update_ref_error(
e: Error,
condition: RefWriteCondition,
transport: &str,
) -> TransportErrorExpand description
Map a server Error reply to an update_ref request into a
TransportError. Shared by mkit-transport-ssh and
mkit-transport-enc so the two clients classify CAS conflicts
identically and cannot drift.
Per SPEC-TRANSPORT §4.2.1, the server signals a compare-and-swap
mismatch as ERROR_CODE_INVALID_REQUEST carrying the current ref
id in details. We treat that as TransportError::RefConflict.
The bare ERROR_CODE_INVALID_REQUEST code alone is ambiguous: the
server reuses it for genuine bad requests (malformed ref, backend
failure) as well as CAS mismatches. To avoid masking a real error as
a conflict we only treat it as RefConflict when:
- the write carried a CAS precondition (
condition != Any), and - the error carries non-empty
details(the documented current-id payload that disambiguates a true CAS mismatch).
When details is absent we fall back to rpc_error_to_transport
so a genuine invalid-request surfaces its real message instead of a
misleading RefConflict. That fallback also covers the rare
conflict-then-ref-absent case (a MATCH expectation against a ref
that does not exist): the server has no current value to put in
details, so the failure surfaces as a RemoteError carrying the
server’s descriptive message.