Skip to content

Regression in error responses from /api/v0/files/rm #8606

@lidel

Description

@lidel

When one causes an error, eg. by attempting to remove an MFS file that does not exist, the error response returned by go-ipfs 0.11.0 is not a valid JSON.

Problem (0.11.0)

Error response in 0.11.0 is plain text:

> curl -X POST -vvv 'http://127.0.0.1:5001/api/v0/files/rm?arg=/foo/keks'                                                                                                                                          ~
*   Trying 127.0.0.1:5001...
* Connected to 127.0.0.1 (127.0.0.1) port 5001 (#0)
> POST /api/v0/files/rm?arg=/foo/keks HTTP/1.1
> Host: 127.0.0.1:5001
> User-Agent: curl/7.79.1
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Access-Control-Allow-Headers: X-Stream-Output, X-Chunked-Output, X-Content-Length
< Access-Control-Expose-Headers: X-Stream-Output, X-Chunked-Output, X-Content-Length
< Content-Type: application/json
< Server: go-ipfs/0.11.0
< Trailer: X-Stream-Error
< Vary: Origin
< X-Chunked-Output: 1
< Date: Tue, 14 Dec 2021 01:12:02 GMT
< Transfer-Encoding: chunked
<
"/foo/keks: parent lookup: file does not exist"
* Connection #0 to host 127.0.0.1 left intact

Before (0.10.0)

0.10.0 had correct error response (JSON):

> curl -X POST -vvv 'http://127.0.0.1:5001/api/v0/files/rm?arg=/foo/keks'                                                                                                                                          ~
*   Trying 127.0.0.1:5001...
* Connected to 127.0.0.1 (127.0.0.1) port 5001 (#0)
> POST /api/v0/files/rm?arg=/foo/keks HTTP/1.1
> Host: 127.0.0.1:5001
> User-Agent: curl/7.79.1
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 500 Internal Server Error
< Access-Control-Allow-Headers: X-Stream-Output, X-Chunked-Output, X-Content-Length
< Access-Control-Expose-Headers: X-Stream-Output, X-Chunked-Output, X-Content-Length
< Content-Type: application/json
< Server: go-ipfs/0.10.0
< Trailer: X-Stream-Error
< Vary: Origin
< Date: Tue, 14 Dec 2021 01:07:30 GMT
< Transfer-Encoding: chunked
<
{"Message":"parent lookup: file does not exist","Code":0,"Type":"error"}
* Connection #0 to host 127.0.0.1 left intact

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugA bug in existing code (including security flaws)need/triageNeeds initial labeling and prioritization

    Type

    No type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions