October 11, 2026•4 min read

A Script That Cannot Say Where It Went Wrong

A script that stops at the first bad line reports only part of the problem. This is what shows up on screen right now.

Read in Indonesian

Lab repo

The lab lives in folder 0005.error-messages

The deliberately broken code, the dataset, and the target live in a public repo. Everything runs in Docker. make check

There is one moment in the life of every small script that always repeats: the first day it receives a file you did not build yourself. While you are the one assembling the .csv, everything is smooth. The moment the file arrives from another team, the phone starts ringing.

The script is simple. It reads a .csv of registrants with three columns — nama, email, umur — then stores the valid rows. One file in, one report out, done. Except when one row is garbage.

What appears then is not an explanation, it is half a screen of report. It starts with Traceback (most recent call last):, followed by a list of file paths, a line number in impor.py, a function name, and at the very bottom a sentence like ValueError: invalid literal for int() with base 10: 'dua puluh'. All of it is accurate. None of it is useful to the person who sent that file.

Key takeaways

  • One useful error message answers three things: where, what is wrong, and what it should be.
  • A script that stops at the first problem answers a third of that. Four problems in one file, zero reported.
  • The broken file sometimes stays silent. kosong.csv reports 3 baris diimpor with exit code 0, while holding a row with no name.
  • The target is make check: seven checks, one green at the initial state.

What people complain about

In this lab, make demo plays five sample files that all go into the same script. What comes out is not uniform across the files, and that is the first problem. The three complaints heard most often:

  • Some files kill the script on the spot. Only the line that happens to trip first gets reported. The broken lines after it are never mentioned, as if they did not exist.
  • Other files stay completely silent. No complaint at all, even though they clearly contain a broken row. The script thanks you instead.
  • The people asking for help complain in the same sentence: "I don't know which line is wrong, which column, or what to do about it." The stack trace names Python variables — baris, umur — not lines in their file.

If you have ever written a small validator or importer, those three complaints feel familiar. The tiring part is not writing the validation, it is explaining the result to someone else. And that, it turns out, is part of the job too.

Measured numbers

No guesses here. Every line below comes from make demo and make check, run at the lab's initial state, as-is:

command what appears now
make impor FILE=data/contoh/beberapa.csv ValueError: invalid literal for int() ... 'dua puluh' — 0 of 4 problems reported
make impor FILE=data/contoh/kosong.csv no complaint, and it says 3 baris diimpor, exit code 0
make impor FILE=data/contoh/kolom.csv IndexError: list index out of range — 0 of 2 problems reported
make impor FILE=data/contoh/tidak-ada.csv FileNotFoundError, exit code 1
make check 1 of 7 checks green (only A)

The first row hurts the most. beberapa.csv holds four problems waiting to be reported, but the program stops at the first and forgets the rest. The third row has the same pattern: kolom.csv has two rows with the wrong number of columns, and neither ever surfaces.

The second row has a different failure shape, and in my view the slickest. kosong.csv contains a row with no name, yet the script cheerfully reports 3 baris diimpor with exit code 0. Nothing red, nothing yellow; and unless you check the source file line by line, you will never know.

Compare that with the last row. There, make check lights only one green lamp out of seven. Those seven checks live in scripts/check.py, and that tool is the judge of this lab.

The limits of this lab

Two things are deliberately out of scope, and both matter so you do not learn the wrong lesson.

First, every error this lab handles is wrong data, not a wrong program. You are validating input that comes from outside. If what is wrong is the logic in your own code (a bug), that is a different story. Second, this is a one-shot program, not a service that stays up. Here "where" means a line number in a file; in a web service, "where" can mean a field in the request body. Same concept, different place. It is also why the exit code matters: scripts like this get called from cron, make, or a shell pipe, not watched by a human staring at the screen.

There is a practical limit too. The report format baris N: kolom — pesan is enough for files this size. Once the file is hundreds of megabytes, reporting every problem at once has its own cost. For now, the size is polite.

Your mission

This lab is deliberately beginner level. To run it you need no Docker, no database — just python3, already installed. What you practise here is not speed or concurrency, but one thing that applies to every language: making a program's failures readable by humans.

Your target is one thing: make make check green, seven out of seven. You may change anything inside app/ however you like. What you must not change: scripts/check.py (that is the grader), data/ (the fixtures), and the Makefile.

If you get stuck, there is HINTS.md with three levels. Use them in order, do not jump to the third. And do not open the solusi branch before you are genuinely stuck.

One question before you start

Before touching a line of code, there is one thing to decide. Who is that report actually for — the machine reading the code, or the person panicking because their registration did not go through?

That question decides every technical choice after it. A program that reports only the first problem it stumbles on is answering a small part of what its user asked. The rest of the answer, and why the fix is as simple as changing one habit, is in the answer article.

If your script stops at the first bad line, what will you never see?

Get better at shipping code.

Join the other developers getting tech updates, tips, and relaxed tutorials in their inbox every week.

Stay in the loop

Tech updates, coding tips, and relaxed insights straight to your inbox every week.

No spam. Unsubscribe anytime.

Read next

See all

For developers who learn by struggling

© 2026 Inva.dev.