You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I found something that's not covered in the batch API spec: validation errors. Validation errors can include things like invalid OID or object size. How should the LFS server respond?
One option is to return the 422 error code on the individual objects in the response. This way the client could continue to upload the other objects, skipping or somehow handling the validation error somehow.
However, I'm leaning towards an HTTP 422 response. These validation errors should only be an issue for people going through the API directly. Hopefully the client is not able to send invalid objects in the request. Also, server backends can roll back an entire DB transaction in the case of a validation error like this, without leaving a partial set of rows.
< HTTP/1.1 422 Unprocessable Entity
< Content-Type: application/vnd.git-lfs+json
<
< {
< "objects": [
< // valid objects can be left out of the response, or just included with no error or action properties
< {
< "oid": "2222222",
< "size": 123,
< "error": {
< "code": 422,
< "message": "Size is invalid"
< }
> }
< ]
< }
Hmm, so is this the only case of this a download request with the size provided from the pointer? You couldn't check upload request sizes, and the oids you can't check without the content.
If that's the case then this indicates a data corruption on one end or the other for that object. I would not personally promote that to a HTTP error, purely because this is a batch API and I don't think errors limited to one object should totally block the rest of the operation, because the user has no real control over the batching process so has no workaround available - even if they'd like to proceed with the other objects. I could see the benefit of promoting to a top-level error on upload, since that would abort a push, but I don't think you'll ever encounter that, the server cannot validate the oid or the size at the time of the batch request, only after the content is received. When downloading if something's gone wrong on the server for a single object, or a single commit locally, I don't think that should block download of anything else that was unlucky enough to be batched up with it, just because that increases the chance of the user getting stuck. In the download case it's not fatal if one object can't be downloaded, so long as the user is notified that something has gone wrong.
Ah no, the validation errors I'm talking about are for uploads. I just copied the api response from the docs with the download action.
When downloading if something's gone wrong on the server for a single object, or a single commit locally, I don't think that should block download of anything else that was unlucky enough to be batched up with it, just because that increases the chance of the user getting stuck.
Agreed here. I think servers would return object errors like 404 or 410 for a missing object.
OK but still for uploads, the server can't check the oid or size just from the batch API call since it hasn't seen the data yet. Only the content server which is receiving the PUT could do that, and since those happen individually, returning a HTTP response (forgetting SSH for the moment) makes sense anyway because it's only one request.
For OID and size validation, we're really talking about things like "is a(ny) sha256 (or whatever kind of hash)" and "is a number greater than 0 (and maybe less than some size limit)".
I think I'm OK with promoting upload validations to the http level. I've tried thinking of reasons to not do it, and can't think of a truly compelling reason (that can't be worked around, see below). I agree that this makes less sense for downloads, and so I think we should definitely not do it there. I also think that even though the error is at the http level, individual objects should still mark themselves as ok/errored.
I'm wondering if we should include some kind of guidance language. Something like objects that don't contain errors MAY be re-batched and sent up, and clients interfacing with git SHOULD abort the high level operation (git push). I don't want to dictate too much client behavior, but I'm ok with using MAY/SHOULD type guidance if it clarifies things.
One thing I would avoid putting in the spec is framing this as related in any way to server side database transactions. That's an implementation detail of the server that may or may not exist, and should not drive our API implementation. For example, even if using some kind of database, a server could recognize these types of validations and return before it even starts any database operations.
For OID and size validation, we're really talking about things like "is a(ny) sha256 (or whatever kind of hash)" and "is a number greater than 0 (and maybe less than some size limit)".
Ah OK, so not really likely from the official client but maybe a custom client issue (or I guess server size restrictions). I agree on promoting it to a HTTP error in the case of an upload because it's important that it's clear the push should be aborted.
I'm wondering if we should include some kind of guidance language. Something like objects that don't contain errors MAY be re-batched and sent up, and clients interfacing with git SHOULD abort the high level operation (git push).
👍
One thing I would avoid putting in the spec is framing this as related in any way to server side database transactions.
Activity
sinbad commentedon Aug 20, 2015
Hmm, so is this the only case of this a download request with the size provided from the pointer? You couldn't check upload request sizes, and the oids you can't check without the content.
If that's the case then this indicates a data corruption on one end or the other for that object. I would not personally promote that to a HTTP error, purely because this is a batch API and I don't think errors limited to one object should totally block the rest of the operation, because the user has no real control over the batching process so has no workaround available - even if they'd like to proceed with the other objects. I could see the benefit of promoting to a top-level error on upload, since that would abort a push, but I don't think you'll ever encounter that, the server cannot validate the oid or the size at the time of the batch request, only after the content is received. When downloading if something's gone wrong on the server for a single object, or a single commit locally, I don't think that should block download of anything else that was unlucky enough to be batched up with it, just because that increases the chance of the user getting stuck. In the download case it's not fatal if one object can't be downloaded, so long as the user is notified that something has gone wrong.
technoweenie commentedon Aug 20, 2015
Ah no, the validation errors I'm talking about are for uploads. I just copied the api response from the docs with the download action.
Agreed here. I think servers would return object errors like 404 or 410 for a missing object.
sinbad commentedon Aug 20, 2015
OK but still for uploads, the server can't check the oid or size just from the batch API call since it hasn't seen the data yet. Only the content server which is receiving the PUT could do that, and since those happen individually, returning a HTTP response (forgetting SSH for the moment) makes sense anyway because it's only one request.
rubyist commentedon Aug 20, 2015
For OID and size validation, we're really talking about things like "is a(ny) sha256 (or whatever kind of hash)" and "is a number greater than 0 (and maybe less than some size limit)".
I think I'm OK with promoting upload validations to the http level. I've tried thinking of reasons to not do it, and can't think of a truly compelling reason (that can't be worked around, see below). I agree that this makes less sense for downloads, and so I think we should definitely not do it there. I also think that even though the error is at the http level, individual objects should still mark themselves as ok/errored.
I'm wondering if we should include some kind of guidance language. Something like objects that don't contain errors
MAYbe re-batched and sent up, and clients interfacing with gitSHOULDabort the high level operation (git push). I don't want to dictate too much client behavior, but I'm ok with usingMAY/SHOULDtype guidance if it clarifies things.One thing I would avoid putting in the spec is framing this as related in any way to server side database transactions. That's an implementation detail of the server that may or may not exist, and should not drive our API implementation. For example, even if using some kind of database, a server could recognize these types of validations and return before it even starts any database operations.
sinbad commentedon Aug 20, 2015
Ah OK, so not really likely from the official client but maybe a custom client issue (or I guess server size restrictions). I agree on promoting it to a HTTP error in the case of an upload because it's important that it's clear the push should be aborted.
👍
Agreed.
technoweenie commentedon Aug 21, 2015
Cool, I think we're all in agreement here. I updated the spec in #599. Does that look ok?