Your Users Are Lying To You A developer recounts how his team's college software failed to validate user input, leading students to submit local file paths instead of URLs, and argues that developers must never trust user input and should validate on both frontend and backend. He recommends schema validation libraries like zod, joi, yup, and Pydantic to prevent issues such as SQL injection. Your users are lying to you. Not necessarily intentionally. Your users can be honest, malicious, or simply sending something your application didn't expect. You might be building a web app, a mobile app, an ML model, an AI agent, or whatever, but if it is being used by users, there are high chances it has some kind of interface and a server. From beginners and college students to big companies, all of them have had small or major failures in handling bad user input. The major reason according to me is assumptions. We make assumptions about the kinds of users of our product, but in this process we forget the following: Recently, in one of the softwares that me and my team had developed for my college, I faced this issue where students were required to upload a PDF file to some storage on the internet like Google Drive or DropBox and enter its URL in a certain form field. We didn't do proper checks on the backend assuming everyone would enter a proper URL. However, certain students for whatever reasons entered the path where the required PDF file was stored on their local computers. This was an innocent and a funny event and did not cause major issues, but strengthened my belief in the fact that we must not make any assumptions about user input. The trouble this could cause is highly variable. It could simply lead to a request failure, or cost you a lot of money. So in my opinion, learning to handle bad user input is really important, and never trusting user input from frontend and handling it on the backend is a rule that I now follow and I recommend every software engineer to do so as well. I will now try to list down few good practices, scenarios, mistakes and their solutions which could help you write better software. These will range from simple to complex issues. However the list is not exhaustive and it is suggested to think over the different cases for your own software. Frontend validation includes allowing only specific inputs and input formats to be sent to the server. This can be done in multiple layers. Taking example of a web app, the first layer would be to use HTML attributes properly. For example, for an email field in a registration form, you can have a tag like this: