Closed aawsome closed 1 year ago
This may be related to the fact that in go empty arrays can be specified as nil
or []type{}
.
see also https://stackoverflow.com/questions/56200925/return-an-empty-array-instead-of-null-with-golang-for-json-return-with-gin
Returning []
seems more reasonable. And it saves 2 bytes ^^ .
Output of
rest-server --version
rest-server version rest-server 0.12.0 compiled with go1.20.3 on linux/amd64
How did you run rest-server exactly?
rest-server --noauth
(but this issue is not related to authentication)curl -X POST localhost:8000/test?create=true
to initialize the repo.curl localhost:8000/index/
orcurl -H "Accept:application/vnd.x.restic.rest.v2" localhost:8000/index/
; both returnnull
(as the repo is empty)What backend/server/service did you use to store the repository?
local
Expected behavior
We are running a list directory command on an empty repository. According to https://restic.readthedocs.io/en/latest/100_references.html#rest-backend, the output should be an empty JSON array, i.e.
[]
.Actual behavior
see above, output is
null
.Steps to reproduce the behavior
see above.
Do you have any idea what may have caused this?
The way rest-server or Go serializes the response doesn't comply to the specification.
Do you have an idea how to solve the issue?
Either change rest-server to comply to the specification (e.g. see
rclone
which seems to implement the specification correctly) - or change the specification telling thatnull
is also a valid response for an empty array.Did rest-server help you today? Did it make you happy in any way?
No - today it only gave me trouble with https://github.com/rustic-rs/rustic, which does implement the REST API as specified ;-)