My Redirect Checker Passed 39 Tests. Two Results Were Still Wrong
An early candidate of my redirect map checker passed all 39 of its tests. Review then found results that no failing test would have exposed. The code did what the tests asked, and the screen still told the user something
An early candidate of my redirect map checker passed all 39 of its tests. Review then found results that no failing test would have exposed. The code did what the tests asked, and the screen still told the user something untrue.
The tool is small. You paste two tab-separated columns, old URL and new URL, and it looks for problems that sit between rows: duplicates, conflicting destinations, self-redirects, loops and chains. It runs in the browser tab and never requests any of the URLs. The build history is in the full case study on CoreAEX. This post is about two of the review findings, because I think they apply to most small diagnostic tools.
Wrong result 1: nothing to check looked like nothing wrong
Here is an illustrative input, constructed for this post:
old_url new_url
A header row and no data. The early candidate could present a paste like that as a map with no issues.
It is easy to see how that happens. This is my reading of it, not a quote from the review notes: zero rows produce zero findings, and zero findings is also what a clean map produces. Each step is defensible, and the result is still false. "I checked your map and found nothing" and "you gave me no map" are different facts, and the user sees only one screen.
Picture someone who copies the wrong range out of a spreadsheet (again, illustrative). They get the same reassurance as someone whose plan really is clean.
The fix: header-only and blank input are now treated as incomplete, not as a clean check.
Wrong result 2: a rejected row created a fake dead end
Some background first. The checker reports a chain when a URL takes two or more hops to reach a URL with no further mapping. If A maps to B and B maps to C, it suggests pointing both sources directly at C.
Now an illustrative map, also constructed for this post. Each row represents the two tab-separated cells a person would paste into the checker:
Old URL New URL
https://example.com/a https://example.com/b
https://example.com/b https://example.com/c
https://example.com/c ftp://example.com/d
The last row's destination uses a scheme the checker does not accept, so that row is rejected as unusable. In the early candidate, that rejection could make C look like the end of the line. The tool would then suggest mapping A straight to C.
But the plan says C is supposed to go somewhere. Where is unknown until someone corrects the row. The suggestion was a confident answer resting on a hole in the data.
The fix: a URL whose outgoing row was rejected is now tracked as blocked, and no final destination is suggested until the invalid row is fixed. The same rule applies more widely. If a path runs into a conflict, a rejected row or a loop before it ends, the checker reports the blocker and suggests nothing.
What the two cases share
In both, the tool treated missing information as if it were information. No rows became "no problems". No usable outgoing row became "no outgoing row".
Input Misleading result What the tool should say
A header with no mappings No issues found The map is incomplete.
A chain whose outgoing row was rejected The last usable URL is the destination The path is blocked; correct the rejected row before suggesting a destination.
My takeaway, which is opinion and not a measured result: a diagnostic tool has at least three answers, and tests tend to cover two of them.
- I checked, and found nothing.
- I checked, and found this.
- I could not check.
The third is the one that leaks into the first. A test that asserts "empty input returns no findings" can pass forever while the interface says "all clear" to a person who pasted nothing. The assertion is about the function. The misleading part is what the result means to the person reading it.
A third example: the right answer to an old question
Review also found that findings could survive an edit to the textbox. You run a check, change a row, and the results from the previous paste could still be on screen.
Each run was correct when it ran. The problem was time: the page showed an answer to a question that was no longer on the page.
Editing now invalidates the result and disables export, and slower rendering work from an earlier run cannot bring old findings back.
Why URLs are exact graph nodes
Each URL is a node and each row is an edge from old to new. Before you can find a loop, you have to decide when two URLs are the same node. The checker compares them as exact, case-sensitive strings. https://example.com/Pricing and https://example.com/pricing are two nodes. So are https://example.com and https://example.com/.
The alternative is guessing. Servers differ on whether a trailing slash, an uppercase path or a reordered query is equivalent, and a checker that quietly merged variants would be asserting server behaviour it cannot see.
There is a catch. The WHATWG URL parser that browsers use rewrites some spellings as it parses: it lowercases ASCII domain names, drops a default port and resolves .. segments, among other changes. Accept the parser's output and the graph contains URLs nobody typed. So when parsing changes a cell's spelling, the checker rejects the cell and names it for correction. The one exception is a host-only URL such as https://example.com, accepted as pasted.
This is the same principle as the two bugs above: the tool should not manufacture certainty it does not have.
Why it does not fetch live redirects
The defects it looks for are properties of the plan. A conflict, a loop or a chain can exist in a spreadsheet before any rule reaches a server, so the pasted rows are the right thing to inspect.
Staying inside the paste also keeps the check deterministic: the same input produces the same findings, with row numbers a person can fix.
It does mean every answer is relative to the paste. In the A, B, C chain, C is terminal only within the map supplied. The checker has not visited C and cannot know whether it redirects again, returns an error or serves the right content.
Where the map check stops
A clean result means the supported checks found nothing in the map you supplied. It does not show that the redirects are deployed, that each source returns the intended redirect, or that destinations return 200. A URL missing from the paste is invisible.
Validating a proposed map and testing deployed behaviour are separate jobs. The first removes plan defects before deployment. The second needs real requests against the real server, through whatever migration checks you already run.
After review, the final report listed 66 passing tests. That is a historical figure from the build record; I did not rerun the suite for this post. The count was never the point anyway. Thirty-nine passing tests described the code. They did not describe what a person would conclude from the screen.
Disclosure: this post was drafted with AI assistance (Claude) from my own published case study, and I reviewed the technical and first-person claims before publishing. As the case study describes, the checker itself was implemented with Claude Code and reviewed before release.
Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.