Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify server behavior if content type is not supported #457

Merged
merged 10 commits into from
Sep 11, 2024
2 changes: 2 additions & 0 deletions apis/beacon/blob_sidecars/blob_sidecars.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,7 @@ get:
example:
code: 404
message: "Block not found"
"406":
$ref: "../../../beacon-node-oapi.yaml#/components/responses/NotAcceptable"
"500":
$ref: "../../../beacon-node-oapi.yaml#/components/responses/InternalError"
2 changes: 2 additions & 0 deletions apis/beacon/blocks/blinded_block.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,7 @@ get:
example:
code: 404
message: "Block not found"
"406":
$ref: "../../../beacon-node-oapi.yaml#/components/responses/NotAcceptable"
"500":
$ref: "../../../beacon-node-oapi.yaml#/components/responses/InternalError"
3 changes: 2 additions & 1 deletion apis/beacon/blocks/block.v2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ get:
- $ref: "../../../beacon-node-oapi.yaml#/components/schemas/Deneb.SignedBeaconBlock"
application/octet-stream:
schema:

description: "SSZ serialized block bytes. Use Accept header to choose this response type"
"400":
description: "The block ID supplied could not be parsed"
Expand All @@ -61,5 +60,7 @@ get:
example:
code: 404
message: "Block not found"
"406":
$ref: "../../../beacon-node-oapi.yaml#/components/responses/NotAcceptable"
"500":
$ref: "../../../beacon-node-oapi.yaml#/components/responses/InternalError"
4 changes: 3 additions & 1 deletion apis/beacon/deposit_snapshot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
summary: "Get Deposit Tree Snapshot"
description: |
Retrieve [EIP-4881](https://eips.ethereum.org/EIPS/eip-4881) Deposit Tree Snapshot.
Depending on `Accept` header it can be returned either as json or as bytes serialzed by SSZ
Depending on `Accept` header it can be returned either as json or as bytes serialized by SSZ
tags:
- Beacon
responses:
Expand All @@ -30,5 +30,7 @@
example:
code: 404
message: "No Finalized Snapshot Available"
"406":
$ref: "../../beacon-node-oapi.yaml#/components/responses/NotAcceptable"
"500":
$ref: '../../beacon-node-oapi.yaml#/components/responses/InternalError'
9 changes: 1 addition & 8 deletions apis/beacon/light_client/bootstrap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,6 @@ get:
code: 404
message: "LC bootstrap unavailable"
"406":
description: Unacceptable media type
content:
application/json:
schema:
$ref: "../../../beacon-node-oapi.yaml#/components/schemas/ErrorMessage"
example:
code: 406
message: "Accepted media type not supported"
$ref: "../../../beacon-node-oapi.yaml#/components/responses/NotAcceptable"
"500":
$ref: "../../../beacon-node-oapi.yaml#/components/responses/InternalError"
9 changes: 1 addition & 8 deletions apis/beacon/light_client/finality_update.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,6 @@ get:
code: 404
message: "LC finality update unavailable"
"406":
description: Unacceptable media type
content:
application/json:
schema:
$ref: "../../../beacon-node-oapi.yaml#/components/schemas/ErrorMessage"
example:
code: 406
message: "Accepted media type not supported"
$ref: "../../../beacon-node-oapi.yaml#/components/responses/NotAcceptable"
"500":
$ref: "../../../beacon-node-oapi.yaml#/components/responses/InternalError"
9 changes: 1 addition & 8 deletions apis/beacon/light_client/optimistic_update.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,6 @@ get:
code: 404
message: "LC optimistic update unavailable"
"406":
description: Unacceptable media type
content:
application/json:
schema:
$ref: "../../../beacon-node-oapi.yaml#/components/schemas/ErrorMessage"
example:
code: 406
message: "Accepted media type not supported"
$ref: "../../../beacon-node-oapi.yaml#/components/responses/NotAcceptable"
"500":
$ref: "../../../beacon-node-oapi.yaml#/components/responses/InternalError"
9 changes: 1 addition & 8 deletions apis/beacon/light_client/updates.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,6 @@ get:
code: 400
message: "Missing `count` value"
"406":
description: Unacceptable media type
content:
application/json:
schema:
$ref: "../../../beacon-node-oapi.yaml#/components/schemas/ErrorMessage"
example:
code: 406
message: "Accepted media type not supported"
$ref: "../../../beacon-node-oapi.yaml#/components/responses/NotAcceptable"
"500":
$ref: "../../../beacon-node-oapi.yaml#/components/responses/InternalError"
2 changes: 2 additions & 0 deletions apis/builder/states/expected_withdrawals.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,7 @@ get:
example:
code: 404
message: "State not found"
"406":
$ref: "../../../beacon-node-oapi.yaml#/components/responses/NotAcceptable"
"500":
$ref: '../../../beacon-node-oapi.yaml#/components/responses/InternalError'
2 changes: 2 additions & 0 deletions apis/debug/state.v2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ get:
example:
code: 404
message: "State not found"
"406":
$ref: "../../beacon-node-oapi.yaml#/components/responses/NotAcceptable"
"500":
$ref: '../../beacon-node-oapi.yaml#/components/responses/InternalError'

2 changes: 2 additions & 0 deletions apis/validator/blinded_block.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ get:
value:
code: 400
message: "Invalid request to produce a block"
"406":
$ref: "../../beacon-node-oapi.yaml#/components/responses/NotAcceptable"
"500":
$ref: '../../beacon-node-oapi.yaml#/components/responses/InternalError'
"503":
Expand Down
2 changes: 2 additions & 0 deletions apis/validator/block.v2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ get:
value:
code: 400
message: "Invalid request to produce a block"
"406":
$ref: "../../beacon-node-oapi.yaml#/components/responses/NotAcceptable"
"500":
$ref: '../../beacon-node-oapi.yaml#/components/responses/InternalError'
"503":
Expand Down
2 changes: 2 additions & 0 deletions apis/validator/block.v3.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ get:
value:
code: 400
message: "Invalid request to produce a block"
"406":
$ref: "../../beacon-node-oapi.yaml#/components/responses/NotAcceptable"
"500":
$ref: '../../beacon-node-oapi.yaml#/components/responses/InternalError'
"503":
Expand Down
14 changes: 11 additions & 3 deletions beacon-node-oapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,15 @@ info:
API specification for the beacon node, which enables users to query and participate in Ethereum 2.0 phase 0 beacon chain.

All requests by default send and receive JSON, and as such should have either or both of the "Content-Type: application/json"
and "Accept: application/json" headers. In addition, some requests can return data in the SSZ format. To indicate that SSZ
data is required in response to a request the header "Accept: application/octet-stream" should be sent. Note that only a subset
of requests can respond with data in SSZ format; these are noted in each individual request.
and "Accept: application/json" headers. In addition, some requests can send and receive data in the SSZ format. The header
"Content-Type: application/octet-stream" should be set in requests that contain SSZ data; a preference to receive SSZ data in
response can be indicated by setting the "Accept: application/octet-stream;q=1.0,application/json;q=0.9" header. Note that
only a subset of requests can respond with data in SSZ format; these are noted in each individual request.

When handling requests, the server should return a 415 status code if the "Content-Type" header in the request specifies a format
that is not supported. Similarly, it should return a 406 status code if it cannot produce a response in the format accepted by
the client as specified in the "Accept" header; if no "Accept" header is provided then it is assumed to be "application/json".
In any case, the server should indicate the format of the response by setting the corresponding "Content-Type" header.

API endpoints are individually versioned. As such, there is no direct relationship between all v1 endpoints, all v2 endpoints,
_etc._ and no such relationship should be inferred. All JSON responses return the requested data under a `data` key in the top
Expand Down Expand Up @@ -413,6 +419,8 @@ components:
$ref: './types/http.yaml#/InvalidRequest'
NotFound:
$ref: './types/http.yaml#/NotFound'
NotAcceptable:
$ref: './types/http.yaml#/NotAcceptable'
UnsupportedMediaType:
$ref: './types/http.yaml#/UnsupportedMediaType'
InternalError:
Expand Down
27 changes: 25 additions & 2 deletions types/http.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -110,16 +110,39 @@ NotFound:
example:
code: 404
message: "Requested item not found"
NotAcceptable:
description: "Accepted media type is not supported."
content:
application/json:
schema:
type: object
required: [code, message]
properties:
code:
description: "The media type in \"Accept\" header is unsupported, and the request has been rejected. This occurs when the server cannot produce a response in the format accepted by the client."
type: number
example: 406
message:
description: "Message describing error"
type: string
stacktraces:
description: "Optional stacktraces, sent when node is in debug mode"
type: array
items:
type: string
example:
code: 406
message: "Accepted media type not supported"
UnsupportedMediaType:
description: "The supplied content-type is not supported."
description: "Supplied content-type is not supported."
content:
application/json:
schema:
type: object
required: [code, message]
properties:
code:
description: "The media type supplied is unsupported, and the request has been rejected. This occurs when a HTTP request supplies a payload in a content-type that the service is not able to accept."
description: "The media type in \"Content-Type\" header is unsupported, and the request has been rejected. This occurs when a HTTP request supplies a payload in a content-type that the server is not able to handle."
type: number
example: 415
message:
Expand Down