Patchwork [3,of,3] lfs: raise an error if the server sends an unsolicited oid

login
register
mail settings
Submitter Matt Harbison
Date Jan. 18, 2018, 3:08 a.m.
Message ID <55a9a666607d88d1accf.1516244917@Envy>
Download mbox | patch
Permalink /patch/26836/
State Accepted
Headers show

Comments

Matt Harbison - Jan. 18, 2018, 3:08 a.m.
# HG changeset patch
# User Matt Harbison <matt_harbison@yahoo.com>
# Date 1516243472 18000
#      Wed Jan 17 21:44:32 2018 -0500
# Node ID 55a9a666607d88d1accf78798f9c85f6635c5eb0
# Parent  c61d1db4baa935aa18c271d0c0011d0f8ff2df88
lfs: raise an error if the server sends an unsolicited oid

This shouldn't happen.  But we shouldn't ignore it if it does, because something
else is likely to go wrong.
Yuya Nishihara - Jan. 18, 2018, 11:52 a.m.
On Wed, 17 Jan 2018 22:08:37 -0500, Matt Harbison wrote:
> # HG changeset patch
> # User Matt Harbison <matt_harbison@yahoo.com>
> # Date 1516243472 18000
> #      Wed Jan 17 21:44:32 2018 -0500
> # Node ID 55a9a666607d88d1accf78798f9c85f6635c5eb0
> # Parent  c61d1db4baa935aa18c271d0c0011d0f8ff2df88
> lfs: raise an error if the server sends an unsolicited oid
> 
> This shouldn't happen.  But we shouldn't ignore it if it does, because something
> else is likely to go wrong.

Queued 2 and 3, thanks.

It would be nice if we can test bad responses.

Patch

diff --git a/hgext/lfs/blobstore.py b/hgext/lfs/blobstore.py
--- a/hgext/lfs/blobstore.py
+++ b/hgext/lfs/blobstore.py
@@ -247,6 +247,10 @@ 
                     raise LfsRemoteError(
                         _(('LFS server error. Remote object '
                           'for "%s" not found: %r')) % (filename, response))
+                else:
+                    raise LfsRemoteError(
+                        _('LFS server error. Unsolicited response for oid %s')
+                        % response['oid'])
             if 'error' in response:
                 raise LfsRemoteError(_('LFS server error: %r') % response)