Skip to content

Chapter 5 of 7

Validation errors at an input boundary

A ValidationError raised where untrusted data enters a program is an expected outcome with a rate, not an incident. Its rendered message carries the value that failed, so logging str(e) writes payload fragments — customer API keys included — into a shared log store, while its errors() list carries field paths and stable codes that aggregate safely. This chapter covers taking the error object apart, logging the shape and returning the value to its sender, and breaking a parse-failure rate down by field before deciding whether a retry, a schema change or a prompt change is the fix.

Python for AI work — read the current version at https://daviddominguez.dev/learn/en/python-for-ai-work/validation-errors-at-an-input-boundary

Back to top