Errata

FastAPI

The errata list is a list of errors and their corrections that were found after the product was released.

The following errata were submitted by our customers and have not yet been approved or disproved by the author or editor. They solely represent the opinion of the customer.

Color Key: Serious technical mistake Minor technical mistake Language or formatting error Typo Question Note Update

Version Location Description Submitted by Date submitted
O'Reilly learning platform Page Chapter 3. FastAPI Tour
HTTP Responses --> Status Code

I'm enjoying this book very much so far (chapter 3). I am very, very confident that it will stay that way :)

The description in the text is correct:
"In the path decorator, specify the HTTP status code that should be returned if all goes well (exceptions will generate their own codes and override it)."

But the code example puts the status code in the parameter list of the path function. It won't generate an error but won't work either.

The code example should look like this:
@app.get("/happy", status_code=202)
def happy():
return ":)"

Ralf Schmitt  Dec 31, 2023 
O'Reilly learning platform Page Example 3-24
Example 3-24

Example, when run with HTTPie returns a HTTP/1.1 405 - Method Not Allowed

Ken LaCrosse  May 17, 2024 
PDF Page Page 79,
Example 6-1.

code:
from fastapi import FastAPI, Depends, Params

problem:
There is no Params module in FastAPI

Anonymous  Jun 05, 2024 
ePub Page Example 3-26
@app.post("/agent")

POST method used in the example causes the following answer:
HTTP/1.1 405 Method Not Allowed
allow: POST
content-length: 31
content-type: application/json
date: Thu, 04 Jul 2024 17:41:08 GMT
server: uvicorn

{
"detail": "Method Not Allowed"
}

But when I change @app.post to @app.get the error disappears.

Tomasz Janicki  Jul 04, 2024 
O'Reilly learning platform Page Chapter 3. FastAPI Tour, Section : HTP Responses
4th Para (Status Code)

In the source code the status code should be defined in path parameter

@app.get("/happy", status_code=200)

but instead it is inside method definition
def happy(status_code=200):

Subhadeep  Jul 16, 2024 
Printed Page 38
Example 3-26. Return the User-Agent header (hello.py)

`@app.post("/agent")` should be `@app.get("/agent")`.

Zhi Li  May 17, 2024 
PDF Page 85
Example 7-5

The example 7-5 should be the copy of the example 3-21 but it is not.
This example is for Fastapi Body and need Body(embed=True) but instead this example is the copy of example 7-3 which is for Fastapi query parameter.

Hossein Tahami  Jul 08, 2024 
PDF Page 98 - 100
Example 8-1 & 8-4

In example 8-1 the (import uvicorn) is inside the
if __name__ == "__main__" but in example 8-4
it is outside the condition.

Hossein Tahami  Jul 08, 2024 
PDF Page 107
Example 8-14

The delete path function in web/explorer.py should return
service.delete(name) but instead it's only returning None exactly like the delete function in fake/explorer.py
Also delete path function in web/creature.py in the next example which is 8-15 is returning service.delete(name) but the 8-14 is not.

Hossein Tahami  Jul 08, 2024 
PDF Page 117
Example 9-1 & 9-2

get_one function in service/creature.py returns data.get(id) but the same function in service/explorer.py returns data.get(name)
argument of this function is <<name>> with string type.

Hossein Tahami  Jul 09, 2024