TL;DR
Continuing our series on Tendero, the AI-native ecommerce platform, in this article I tell the story of a bug that should have been impossible: a shop where every product existed and none of them could be found.
- All tests were green, the search quality gate scored 0.860, Elasticsearch was up, and search returned zero results on every machine.
- The cause was not inside any component. It was an arrow in a state machine that no code ever walked.
- Looking for other missing arrows found two more the same week, and a five-line search finds them in your own code.
Zero results
All tests passed.
The search quality gate scored 0.860, as it had every day since it was built.
Elasticsearch was up. Both search indexes existed.
Six products were in Postgres, freshly imported.
And a search for «cafetera» — a coffee pot, in Spanish — returned this:
{"hits":[],"total":0}
How can all of that be true at the same time?
The easy answer was wrong
The bug report was one sentence: the storefront finds nothing for «cafetera». It was 2026-08-31, and Tendero, the open-source .NET and Angular shop this series is about, had six products. (It has 120 today.)
The first check gave an easy answer: nothing had ever been imported on that machine. An empty database gives an empty search.
So I imported the catalogue. Six products arrived in Postgres.
Search still returned zero.
Following the evidence
Elasticsearch was not a suspect for long. Both indexes answered queries, and both held zero documents. Search was not failing to find the products. Nobody had ever given them to it.
So the question changed: not «why can’t search find them?» but «why did nobody index them?»
In Tendero, the search index is a projection of Postgres: a copy built from it, only for reading. When a product changes, the domain raises an event, the outbox keeps it until a worker delivers it, and the worker updates the index with one short rule (simplified here):
if (product.Status == ProductStatus.Active) await indexer.IndexAsync(product, ct);else await indexer.RemoveAsync(product.Id, ct);
→ Reference: src/Search/Contracts.cs, lines 107–130, the rule in full
Only Active products reach search. A good rule: search should not show what is not on sale.
All six products were Draft. Also a good rule: a product from a supplier’s file waits for a person to review it before it goes on sale.
Two correct rules. One question left.
The question I should have asked first
Who moves a product from Draft to Active?
The domain had the method, Product.Publish(). It had tests. It worked.
I searched src/ for a caller.
Nobody.
A product’s life is a small state machine — Draft, Active, Archived. The arrow from Draft to Active was in the design, the domain and the tests, with no code behind it: the review queue that would call it was planned for a later phase. Whatever you imported, on any machine, search would answer zero.
The bug was not inside any box. It was an arrow that nothing walked.
Why every test was still green
The search quality test is the one article 03 built: a golden set of real queries, each with a person’s judgement of which products should answer it, scored with NDCG@10 — a number from 0 to 1 that says how close the first ten results are to the ideal order. It is not a mock: it indexes the seed catalogue through the real ports and asks real queries.
It passed because the tool that builds its catalogue publishes every product itself:
var product = external.ToNewProduct(source, Clock, definitions);product.Publish(Clock);return product;
→ Reference: tools/SearchEval/SeedCorpus.cs, lines 97–115
The comment above it says why: only Active is searchable, and there is no review queue here to publish it. Whoever wrote that workaround saw the hole and wrote it down, in the right file. The workaround is right for a tool that measures ranking. But the only test that measured search never walked the one path that was broken, and it went green every day while the hole stayed open.
A comment that describes a hole is not a test that fails while the hole is open.
The fix was small. That was the point.
The missing piece was a slice called PublishProduct: load the product, refuse an archived one, call Publish(), save. (The handler is 26 lines.) It was never hard. It was only missing.
One branch deserves a word: publishing a product that is already Active — two reviewers will, and so will an agent that retries — answers AlreadyActive and saves nothing, so no second event makes the indexer write the same document again. A test holds it.
Measured on the six-product catalogue, on 2026-08-31:
| before publishing | after publishing | |
|---|---|---|
| products in Postgres | 6 (all Draft) | 6 (all Active) |
documents in products_es | 0 | 6 |
q=cafetera&culture=es | 0 hits | 1 hit, score 8.91 |
Why had nobody noticed? Because every check looked at one piece, and each piece was right.
We started looking for other missing arrows
If one arrow had no code behind it, others might not either. I looked in three places: the answer the new endpoint sent, the life of the index itself, and — much later — the whole domain.
The answer on the wire
The new slice had five passing unit tests. The endpoint answered this:
{"outcome":1,"productId":{"value":"01a05871-…"},"status":"active"}
The id leaks out as an object, because ProductId is a strongly-typed record struct, while the search endpoint of the same API sends ids as plain strings. And "outcome":1 means nothing to a caller — an AI agent cannot guess it — and turns wrong the day someone reorders the enum.
The handler was right; its answer on the wire was not. No unit test reads the wire. One curl did.
It became two rules for the whole API: ids leave as plain strings, and enums leave by their C# names, through one converter, with contract tests on every endpoint (ADR 0043, the response today).
Strongly-typed ids are a win in the domain and a trap in the serialiser, and the trap only opens at the boundary.
The index that could not come back
Postgres is the source of truth; the index is only a copy. That is why Elasticsearch runs without a volume, on purpose: a copy you cannot rebuild is a second database.
But nothing rebuilt it. When the container was recreated, the index came back empty while the whole catalogue was Active in Postgres, and the outbox had already delivered its events.
So ReindexProducts was born, applying the same function as the worker to every product. That makes the index converge on the truth; a rebuild that only adds would keep every product that stopped being Active.
Converging has a blind spot. While resetting the catalogue for a UI test, I deleted the six products with SQL and imported them again.
Twelve documents for six products.
The rebuild cannot remove what no longer exists. The application never deletes a product, so it takes a DELETE by hand or a restored backup — but it is real. The repair is POST /api/search/reindex?recreate=true: it drops the indexes, creates them from the one place that owns their mapping and replays the catalogue. It is manual, because it empties search for a few seconds.
Every method only the tests call
Look again at what Publish() had: it was written, it had tests, and a tool called it. Only the application never did. A domain method that only your tests call is a warning sign, and you can search for it.
Your IDE’s Find Usages, scoped to production code, checks one method. Five lines of bash check a whole project (change the paths for yours):
for m in $(grep -rhoE 'public [A-Za-z<>?]+ [A-Z][A-Za-z]*\(' src/*/Domain | sed -E 's/.* ([A-Za-z]+)\($/\1/' | sort -u); do prod=$(grep -rlE "\.$m\(" src --include=*.cs | grep -v /Domain/ | wc -l) test=$(grep -rlE "\.$m\(" tests tools --include=*.cs | wc -l) [ "$prod" -eq 0 ] && [ "$test" -gt 0 ] && echo "$m: called only from tests or tools ($test files)"done
On the code of 2026-08-31, the day before the fix, it lists 7 of 14 method names: six steps of an order, for a checkout that did not exist yet, and Publish.
The bug of this article, found by a search, before anybody typed «cafetera».
On today’s code it lists 10 of 154. One is Archive(): the domain, search and publishing all handle an archived product, and nothing lets a person archive one. The same missing arrow, one state further. Another is FailPayment(), which the payment webhook stopped calling, kept alive by its tests. Both are on the board now.
Each line is a missing feature, dead code or a feature still to come, and a person decides which. It matches names, not methods, and misses static methods and reflection; a Roslyn analyser is the exact version.
The pattern
| piece A | piece B | the missing arrow between them |
|---|---|---|
| a product in Draft | search over Active | the step that publishes |
| the handler’s result | the JSON a client reads | one look at the wire |
| the data in Postgres | the search index | a way to rebuild it |
Every piece was correct, and every piece had its tests. None of that said anything about the way from one piece to the next.
Unit tests check the boxes. These bugs live in the arrows.
What I take to every project
- Every state has a way in and a way out in production code.
- A comment that explains a workaround is a task: put it on the board, or write a test that fails while it is true.
- Look at the real answer once, at the boundary, before deciding what to automate.
- A projection can be dropped and rebuilt, and it converges.
- Run the system cold, on an empty machine.
Every box in this story was right. The shop was still empty — because the one thing nobody tested was the way from one box to the next.
The repository is public and MIT licensed, and the code exactly as this article describes it is tagged blog/07-the-catalogue-nobody-could-find. ADR 0012 records the decisions behind publishing and reindexing.
How we know it works
- The tests that fail: I removed the handler’s
AlreadyActiveguard on purpose, and two tests turned red. I changed the index rule to keep drafts too, and three rebuild tests turned red, among themReindexing_removes_what_is_no_longer_active. - The check on every pull request: the publish and rebuild tests, the contract tests that hold the enums on the wire to their names, and the search quality test.
- The mutation score:
Contracts.cs, the index rule’s file, scored 81.11 % of covered in Stryker at the close of phase 13b.PublishProducthas not been in a Stryker run yet, so its mutation was made by hand. Article 04 explains how to read the score.
Next article: Your build is green and nothing works — this one was a missing line of code; the next one is two dependencies declared wrong, and no line of code was wrong at all.
Tendero — commerce for humans and agents.

