The Answer Was Right, the Question Was Wrong¶
Learning objectives
- Why a correct fail-closed denial can still be a defect — located in the caller, not the policy
- How reusing a permission check across two different operations silently imports the wrong question
- Why deferring a decision until the evidence exists is a design win that creates one specific new failure mode
- How to read a denial: "you may not" and "you asked something unanswerable" are different sentences
- Why a passing test is a claim rather than evidence, and the three shapes that pass while guarding nothing
- How deliberately breaking your own fix turns a green suite back into proof
Two ways to be wrong while everything reports success¶
This article is about two failures that look nothing alike and are the same mistake.
In the first, a security policy refused an operation and the refusal was completely correct. Nobody had misconfigured anything. The rule was written as intended and executed as written. The operation was still broken.
In the second, a test suite went green and proved nothing at all — three separate times, in three different ways, on three tests written specifically to guard fixes that mattered.
The common root: an answer was accepted without anyone checking which question produced it. A denial is an answer. A passing test is an answer. Both are worthless until you know what was asked.
Part one — a gate can be right while the caller is wrong¶
The denial¶
Picture a system that has deliberately split one operation into two.
The old design had a single button. Point it at a folder, and it would enumerate everything under it and open every file it found, in one motion, on one consent. The new design separates those: one operation reads only structure — names, sizes, dates, the shape of the tree — and opens nothing. A second, later, separately-consented operation is the one that reads contents.
That split is the whole point of the product. It also means the two operations are no longer the same kind of act, and their permission questions cannot be the same question.
The new read-only operation was wired up. Its first live run failed immediately, at zero items, with a policy denial.
Why the denial was correct¶
The read-only operation had reused the permission check belonging to the older, content-reading path. That check asks a perfectly sensible question: what is the sensitivity classification of the documents involved, and does that classification permit this destination?
But the redesign had deliberately stopped asking for a classification at folder-selection time. That was not an oversight; it was the central product decision. You cannot honestly classify documents nobody has opened. The right moment to answer that question is later, once there is evidence to answer it with.
So the classification was absent — by design, correctly, exactly as specified. The policy received a null classification, found no rank corresponding to it, and denied. Fail-closed did precisely its job. An unrecognized classification is not a permissive default; it is a refusal. Had the policy done anything else, it would have been the bug.
The defect was one layer up. The operation was asking a question that had no meaningful answer at that point in the journey. An operation that opens no files classifies no documents. The question it actually needs answered is a different one entirely — a question about the tenant, not about the documents — and that one had been answered long before, at signup.
The rule to take away¶
When a policy denies you, the first thing to check is not whether the policy is too strict. It is whether you are asking it something it can answer.
Three failure shapes hide under a single denial, and they have completely different fixes:
- The policy is wrong. The rule does not express the intent. Fix the rule. This is the case everyone assumes first, and it is the rarest.
- The caller is unauthorized. The system is working. Do not fix anything.
- The caller asked the wrong question. The inputs are structurally unanswerable for this operation, so the policy cannot do anything but refuse. Fix the call site.
Reaching for case 1 when you are in case 3 is how good policies get loosened to accommodate bad calls. The loosening usually works — the denial goes away — and it works by removing the guarantee that made the policy worth having. A weakened rule that lets a null classification pass does not just unblock the read-only operation; it unblocks everything else that ever passes a null.
The trap that comes with deferring a decision¶
The design move here — do not ask a question until the evidence to answer it exists — is a genuinely good one, and it is worth naming the specific hazard it introduces.
Deferring a decision means some part of your system now runs in a state where a field that used to be populated is legitimately empty. Every gate downstream of that field was written when the field was always present. None of them were reconsidered. They will all behave correctly and refuse, and every one of those refusals will look like a policy problem.
So: when you defer a decision, inventory every check that reads the deferred value. For each one, ask which of these it is —
- It genuinely needs the value → it belongs after the deferral point.
- It never needed the value → give it the question it actually needs.
- It needs a value and any will do → that is not a security check, and you should find out what it was really for.
Fixing the denial in this case exposed exactly this: the same unanswerable-question failure was lying latent on the other path too, reachable through a timing window where the classification had not yet been written. It had never fired, so nothing had ever reported it. It would have, eventually, on someone's real data. One incident, two bugs — because the inventory got done rather than just the hotfix.
And say which one it was¶
A denial that only says "denied" forces every future reader through this same analysis from scratch. A denial that names the failing input — "classification: absent; no rank defined" — hands the reader the answer. The cheapest improvement available to any policy engine is making its refusals say what they refused on.
Part two — a test that passes when the fix is removed is decoration¶
Now the same mistake wearing the opposite costume.
A green test is not evidence that the thing it guards works. It is evidence that the assertion it makes was satisfied. Those coincide only when the test actually exercises the mechanism, and it is remarkably easy to write one that does not.
Three of them turned up in a single build. They are worth studying because they fail in three genuinely different ways, and between them they cover most of the ways this happens.
Shape one — the path that never fires¶
A long-running job has to hand off to a fresh execution when it grows too large to continue in one. That handoff is delicate, so it got a test.
The test fed the job a small amount of work — small enough that the size threshold was never crossed. The handoff never triggered. What the test observed as "the resumed run" was the same execution, still looping, never having handed off to anything.
It passed. It had never once exercised the mechanism it was named after.
The tell: a test for a conditional path that never asserts the condition was reached. If a mechanism only activates past a threshold, the test must either cross the threshold with real volume or lower the threshold to something it can cross — and then assert, explicitly, that the transition happened.
Shape two — the assertion bound too narrowly¶
A guard exists to stop sensitive values from appearing in output. It got a test: produce output, assert the sensitive value is not in it.
Except the assertion was scoped to one component of the output. The same leak, rendered through a sibling component built the same way, sailed straight past. The suite was green while the defect was still shipping in the next element over.
The tell: the fix applies to a class of things; the test names one member of the class. When a defect has siblings, enumerate them and assert over the whole set, ideally by iterating a list that fails loudly when someone adds a new member without covering it.
Shape three — the input derived from the thing under test¶
The subtlest one. A sweep existed to catch an inconsistency between two views of the same data — the two should always agree, and the test was there to catch the day they did not.
The sweep built its input by deriving it from one of the views. So the input was consistent by construction. The disagreement it existed to detect was not merely unlikely in that harness; it was unconstructable. The test could run forever, on every commit, and never once be capable of failing.
The tell: the test's fixture is computed from the same source as the thing being asserted. If your expected value and your actual value trace back to one origin, you are asserting that a number equals itself. Independent verification requires an independent input — stated explicitly, ideally by hand.
The routine that finds all three¶
There is one practice that catches every shape above, and it costs minutes: break the fix on purpose and confirm the named test goes red.
Remove the guard. Invert the condition. Delete the branch. Run the test that is supposed to be watching it. If it still passes, you have learned something far more valuable than another green run — you have learned that this test has never been protecting anything, and possibly never could. Then put the fix back.
That is mutation testing, and it does not require a framework to start doing. The framework versions automate the mutations across a whole codebase, which is worth having. But the habit that matters is smaller and available today: for any test you are relying on, watch it fail once, on purpose, for the reason it exists. A test you have never seen fail is a test whose failure mode is unverified.
Two corollaries worth keeping:
- Write the failing case first when you can. A test that has failed for the right reason before it passed has already proved it can.
- A test added alongside a fix deserves this treatment most. That test exists to stop one specific regression, and it is the only thing standing between you and a repeat. It is exactly the test you most want to be real, and — written in the relief of having just fixed something — exactly the one most likely to be shaped by the fix rather than by the bug.
The common root¶
A denial and a passing test are both answers. Neither one tells you anything until you know what was asked.
The correct-but-useless denial happened because a caller assumed that "the policy said no" meant "the policy is the problem," when the policy was faithfully answering a question that had no answer. The three hollow tests happened because their authors assumed that "the suite is green" meant "the mechanism works," when the suite was faithfully reporting on assertions that never touched the mechanism.
In both cases the machinery was honest and the interpretation was not. The discipline is the same in both directions: before you trust a result, reconstruct the question that produced it. For a gate, that means checking your inputs are answerable before you touch the rule. For a test, it means breaking the thing it guards and watching it notice.
The takeaway
A fail-closed policy that refuses an operation may be completely correct while the operation is completely broken — the bug lives at the call site, in a question that had no meaningful answer at that point. Check the answerability of your inputs before you loosen a rule, and when you defer a decision to where the evidence lives, inventory every check that reads the deferred value. The mirror image is a green test that guards nothing: a path that never fired, an assertion bound one element too narrowly, an input derived from the very thing it was checking. Both are answers accepted without examining the question. Break your own fix on purpose and watch the named test go red — a test you have never seen fail is decoration.