Module 04 Knowledge Check
5 questions. Pass mark 4 out of 5. Answer every question before checking the answer key below, then retry after reading the feedback.
1. An optional value belongs in…
- A. the path
- B. the query string
- C. the body always
- D. a header
2. A pagination limit without a maximum is…
- A. convenient
- B. a denial-of-service vector in your own code
- C. required by REST
- D. handled by FastAPI
3. Body constraints declared on the model…
- A. run inside the handler
- B. run before the handler and appear in the docs
- C. must be duplicated in the handler
- D. only apply in production
4. Reading a header from the raw request object…
- A. is the recommended approach
- B. makes it invisible to the schema and validation
- C. is faster
- D. is required for custom headers
5. A ?user_id= parameter used as identity is…
- A. convenient and fine
- B. the caller asking to be trusted
- C. standard practice
- D. equivalent to a header
---
Answer Key and Explanations
Check these only after attempting every question.
1. B - the query string
An optional path parameter forces two routes or a sentinel value in the URL.
2. B - a denial-of-service vector in your own code
A caller can ask for a million rows and your database will try.
3. B - run before the handler and appear in the docs
That is validation you did not write and cannot forget to call.
4. B - makes it invisible to the schema and validation
Declare it in the signature so it reaches the contract.
5. B - the caller asking to be trusted
Identity must be derived from a credential you verified.
Practical Check
Apply this module to your own work: complete the module activity for *Path, Query and Body Parameters*, then write one sentence naming what your result shows and one naming what it does not.
Strong Answer Pattern
A strong answer names the task, the evidence used, the check performed, and the remaining limitation. It avoids "proved", "guaranteed", or "always" unless the evidence genuinely supports it.
