iterative / scmrepo

SCM wrapper and fsspec filesystem for Git for use in DVC.
https://dvc.org
Apache License 2.0
21 stars 13 forks source link

lfs: add missing `Accept` header to Batch API request #302

Closed sisp closed 9 months ago

sisp commented 9 months ago

I've fixed the Batch API request header to include Accept: application/vnd.git-lfs+json as stated in the spec:

All Batch API requests use the POST verb, and require the following HTTP headers. The request and response bodies are JSON.

Accept: application/vnd.git-lfs+json
Content-Type: application/vnd.git-lfs+json

For instance, omitting this header leads to an error when fetching LFS objects from github.com:

$ dvc import https://github.com/githubschool/lfs-example TogglDesktop-7_4_373.dmg
Importing 'TogglDesktop-7_4_373.dmg (https://github.com/githubschool/lfs-example)' -> 'TogglDesktop-7_4_373.dmg'
...
Could not open LFS object, falling back to raw pointer
...

github.com responds to the Batch API request with HTTP status code 406 and the following response body:

{"message":"Not Acceptable","documentation_url":"https://support.github.com/contact"}

When the Accept header is included, it works fine.