A hibák a fájlok között laknakBugs live between files
Minden fájl hibátlanul lefordult, a szintaxiskapu zöld volt – az alkalmazás mégsem indult el. Ezért építettünk egy kaput, amely a fájlokat egymáshoz méri, kódfuttatás nélkül.
Every file compiled cleanly and the syntax gate was green – yet the app wouldn’t start. So we built a gate that checks files against each other, without running any code.
A probléma: egyenként minden rendbenThe problem: each file is fine on its own
Az FRST-ben több munkás dolgozik párhuzamosan, mindegyik a saját fájljain. A szintaxiskapu fájlonként ellenőriz, és egy valódi mérési futásban minden fájl átment rajta. Aztán jött ez:
In FRST several workers write in parallel, each on their own files. The syntax gate checks one file at a time, and in a real measurement run every file passed. Then came this:
# szemléltetés
ImportError: cannot import name 'notes' from 'app.notes'
# illustration
ImportError: cannot import name 'notes' from 'app.notes'
Az egyik munkás egy notes nevet importált, amely a másik fájlban nem létezett – ott create_note, delete_note, get_notes és notes_bp volt. Mindkét fájl önmagában helyes, együtt nem működnek. Az a futás így ment el négy körön át.
One worker imported a name, notes, that didn’t exist in the other file – which had create_note, delete_note, get_notes and notes_bp. Each file was correct on its own; together they didn’t work. That run burned through four rounds this way.
A hiba nem egy fájlban volt, hanem kettő között.
The bug wasn’t in a file. It was between two of them.
Egy ilyen importhiba ráadásul mindent megakaszt. Amíg egy modul be sem töltődik, a hozzá tartozó tesztek sem futnak le, így a csapat nem is a valódi kérdésről – működik-e a funkció – kap visszajelzést, hanem csak arról, hogy valami nem indul el. A szintaxiskapu pedig nem segíthetett: az fájlonként néz, és fájlonként nem volt hiba.
An import error like this also blocks everything else. As long as a module fails to load, its tests don’t run either, so the team gets no feedback on the real question – does the feature work? – only that something won’t start. And the syntax gate couldn’t help: it looks at one file at a time, and file by file there was nothing wrong.
A megoldás: keresztfájl-kapuThe fix: a cross-file gate
A keresztfájl-kapu a szintaxiskapu része. Kódot nem futtat, csak olvas: összeveti, amit egy fájl hivatkozik, azzal, ami a másikban ténylegesen létezik. Amit ma ellenőriz:
The cross-file gate is part of the syntax gate. It runs no code; it only reads, comparing what one file refers to with what actually exists in another. What it checks today:
- Python: az importált nevek léteznek-e a célmodulban.
- Flask: a
render_template,extendsésincludesablonjai; azurl_forvégpontjai (blueprintekkel együtt); arequest.formkulcsai és az űrlapmezők egyezése. - JS/TS: a relatív importok célja, a nevesített és a default exportok – ESM és CommonJS esetén is.
- Frontend ↔ szerver: a
fetch/axioshívások útvonala és metódusa létezik-e a szerveren (Express vagy Flask). - PHP: az
include/requirecélja – kivéve a futásidőben készülőconfig.php-t.
- Python: whether imported names exist in the target module.
- Flask: templates in
render_template,extendsandinclude; endpoints inurl_for(blueprints included);request.formkeys against form fields. - JS/TS: relative import targets, named and default exports – for both ESM and CommonJS.
- Frontend ↔ server: whether the route and method of each
fetch/axioscall exist on the server (Express or Flask). - PHP:
include/requiretargets – exceptconfig.php, which is generated at runtime.
Mivel semmit nem futtat, a kapu gyors és olcsó, és a tesztek előtt szól – vagyis a hibát még azelőtt jelzi, hogy egy importhiba elrejtené a tesztek eredményét.
Because it runs nothing, the gate is fast and cheap, and it speaks up before the tests do – flagging the problem before an import error can hide the test results.
Használható hibaüzenetAn error message you can act on
A kapu a hibát fájl:sor pontossággal adja vissza, a ténylegesen létező nevek felsorolásával, és a hibás fájl gazdájának küldi. Például:
The gate reports the problem with file:line precision, lists the names that do exist, and sends it to the owner of the faulty file. For example:
'notes' nem létezik az app/notes.py-ban – ott ez van:
create_note, delete_note, get_notes, notes_bp
'notes' does not exist in app/notes.py – it has:
create_note, delete_note, get_notes, notes_bp
Egy ilyen üzenetből a munkásnak nem kell kitalálnia semmit: látja, mit akart, és látja, mi van. A javítás egyetlen sor.
With a message like this the worker doesn’t have to guess anything: it sees what it asked for and what is actually there. The fix is one line.
Inkább hallgat, mint hamis pirosat adBetter silent than falsely red
Egy statikus ellenőrzés könnyen túlbuzgó lesz. Ha a kapu hamis pirosat ad, a munkások jó kódot kezdenek „javítani”, ami pénzbe kerül és új hibákat szül. Ezért óvatosra terveztük: ha a szerkezet nem egyértelmű – például ismeretlen útvonal-előtagot lát –, az adott ellenőrzést kihagyja.
A static check can easily become overeager. If the gate raises a false red, workers start “fixing” good code, which costs money and creates new bugs. So we designed it to be cautious: when the structure is ambiguous – say, an unknown route prefix – it skips that check.
MérésMeasurement
| Próba | Eredmény |
|---|---|
| 8 korábban átment valódi projekt | 0 hamis jelzés |
| 6 szándékos hiba (mutáció) | 6/6 elkapva |
| A valódi ImportError | azonnal megnevezte |
| Check | Result |
|---|---|
| 8 real projects that had passed before | 0 false alarms |
| 6 deliberate bugs (mutations) | 6/6 caught |
| The real ImportError | named immediately |
Tanulság. A legolcsóbb hiba az, amit futtatás nélkül, a fájlok összevetéséből meg lehet fogni.
Takeaway. The cheapest bug is the one you can catch without running anything, just by comparing files.