Level 7 / Project 09 - Contract Version Checker¶
Home: README
Learn Your Way¶
| Read | Build | Watch | Test | Review | Visualize | Try |
|---|---|---|---|---|---|---|
| — | This project | — | — | Flashcards | — | — |
Focus¶
- payload version compatibility checks
Why this project exists¶
This project gives you level-appropriate practice in a realistic operations context. Goal: run the baseline, alter behavior, break one assumption, recover safely, and explain the fix.
Run (copy/paste)¶
Use <repo-root> as the folder containing this repository's README.md.
cd <repo-root>/projects/level-7/09-contract-version-checker
python project.py --input data/sample_input.txt --output data/output_summary.json
pytest -q
Expected terminal output¶
Expected artifacts¶
data/output_summary.json- Passing tests
- Updated
notes.md
Alter it (required)¶
- Add a
"nullable"attribute to ContractField so a field can be present but None. - Add a
backwards_compatible()function that checks if new contract is safe to deploy. - Re-run script and tests — verify nullable fields and compatibility check work.
Break it (required)¶
- Pass a version string with only two parts (e.g.
"2.1") and watchparse_versioncrash. - Send a payload where a required field is present but set to
None. - Observe the IndexError or false-positive validation pass.
Fix it (required)¶
- Pad missing version parts with zero (e.g.
"2.1"becomes"2.1.0"). - Treat
Nonevalues as missing for required fields invalidate_payload. - Add tests for two-part versions and None-valued required fields.
Explain it (teach-back)¶
- Why is semantic versioning important for API contracts?
- What happened when the version string had only two parts?
- How did the padding fix prevent the IndexError?
- How do real API platforms handle breaking vs non-breaking changes?
Mastery check¶
You can move on when you can: - run baseline without docs, - explain one core function line-by-line, - break and recover in one session, - keep tests passing after your change.
Related Concepts¶
- Errors and Debugging
- Files and Paths
- Functions Explained
- How Imports Work
- Quiz: Errors and Debugging
| ← Prev | Home | Next → |
|---|---|---|