Skip to content

Commit 289ab53

Browse files
committed
Auto merge of #10860 - Eh2406:4xxDocs, r=ehuss
servers should use 404 Clarify the docs in lieu of our conversation at https://rust-lang.zulipchat.com/#narrow/stream/246057-t-cargo/topic/Sparse.20Registry.20Errors
2 parents 44684e0 + c032c25 commit 289ab53

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/doc/src/reference/registries.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -320,9 +320,10 @@ visit the registry's website to obtain a token, and Cargo can store the token
320320
using the [`cargo login`] command, or by passing the token on the
321321
command-line.
322322

323-
Responses use a 200 response code for both success and errors. Cargo looks at
324-
the JSON response to determine if there was success or failure. Failure
325-
responses have a JSON object with the following structure:
323+
Responses use the 200 response code for success.
324+
Errors should use an appropriate response code, such as 404.
325+
Failure
326+
responses should have a JSON object with the following structure:
326327

327328
```javascript
328329
{
@@ -336,10 +337,10 @@ responses have a JSON object with the following structure:
336337
}
337338
```
338339

339-
Servers may also respond with a 404 response code to indicate the requested
340-
resource is not found (for example, an unknown crate name). However, using a
341-
200 response with an `errors` object allows a registry to provide a more
342-
detailed error message if desired.
340+
If the response has this structure Cargo will display the detailed message to the user, even if the response code is 200.
341+
If the response code indicates an error and the content does not have this structure, Cargo will display to the user a
342+
message intended to help debugging the server error. A server returning an `errors` object allows a registry to provide a more
343+
detailed or user-centric error message.
343344

344345
For backwards compatibility, servers should ignore any unexpected query
345346
parameters or JSON fields. If a JSON field is missing, it should be assumed to

0 commit comments

Comments
 (0)