kzwang / node-git-lfs

A NodeJS implementation of Git LFS Server.
Apache License 2.0
57 stars 37 forks source link

422 Unprocessable Entity on push #5

Open Dermah opened 4 years ago

Dermah commented 4 years ago

I'm getting a 422 Unprocessable Entity error from node-git-lfs when trying to push to the server using git-lfs/2.11.0.

I dug in to it and it looks like the error is thrown when validating the batch request here: https://github.com/kzwang/node-git-lfs/blob/ebbe7d88a796428f313cf6efdb1dffbf7f791fd3/lib/routes/batch.js#L100-L110

My git-lfs client sends through a body that looks like this

{ operation: 'upload',
  objects:
   [ { oid:
        '19f2dcd3b4f260b2d6e5cdec56c58d2b150526b262cb0ca15b8d86eb6398d3dd',
       size: 386583 } ],
  transfers: [ 'lfs-standalone-file', 'basic' ],
  ref: { name: 'refs/heads/master' } }

I think the transfers and ref keys are failed by the JSON schema validation. Removing this line from the schema makes everything work smoothly: https://github.com/kzwang/node-git-lfs/blob/ebbe7d88a796428f313cf6efdb1dffbf7f791fd3/schema/http-v1-batch-request-schema.json#L27

Dermah commented 4 years ago

Ah yeah the actual schema published in git-lfs is slightly different to the one that exists in this repo