Watch out for errors during deployment
Route conflict errors during deployment
Please note the following: If you already deployed an API definition before with the same path /{user-id}/get-cart-contents
,
then you will receive a conflict error as given below.
API deployment definitions conflict error: /{user-id}/get-cart-contents
This implies, when you update the version, you have to update the path as well, such as /v5/{user-id}/get-cart-contents
under the path
field in route
.
Watch out for more errors during API definition and deployment updates
Please read through how to update API definitions and deployments to understand possible errors and how to manage them.
BadRequest errors when invoking the API with inputs
If your API's implementation (Rib script which internally calls workers) gets a wrong input (Example: wrong types in http request),
it produces a BadRequest
. This makes Golem Gateway much more type safe than a typical Gateway
where it always routes to the backend regardless of wrong inputs.
Here is an example:
Based on the below Rib script which is part of workerName
in API definition, the user-id
in the path
should be of the type u64
.
let user: u64 = request.path.user-id; \"my-worker-${user}\""
This implies Rib expects the input user-id
to be u64
. Otherwise, it will fail with BadRequestError
>
* Request completely sent off
< HTTP/1.1 400 Bad Request
< access-control-allow-origin: *
< content-length: 392
< date: Tue, 10 Dec 2024 03:42:54 GMT
<
* Connection #1 to host localhost left intact
Input request details don't match the requirements for rib expression to execute: Invalid value for the key path.
Error: Invalid value for the key user-id. Error: Expected function parameter type is u64. But found string.
Requirements. Record(TypeRecord { fields: [NameTypePair { name: "path", typ: Record(TypeRecord { fields: [NameTypePair { name: "user-id", typ: U64(TypeU64) }] }) }] })%
This implies the request
input should have a field called path
in it, which in turn has a field called user-id
,
and its type should be u64.