Pendora takes a person's official pension and insurance snapshot and turns the raw industry data feed into a plain dashboard of what they own and what they are covered for. One of the questions the app has to answer from that feed is whether a given policy is active. This note covers why that check is written the way it is.
Why does a substring check give the wrong answer for policy status?
A substring check asks whether the status text contains the word for 'active'. That is only safe if no other status value also contains that word. In the language the feed is written in, the phrase for 'not active' contains the word for 'active' as a substring. A contains-style check would therefore return true for both values. The test meant to separate active policies from inactive ones would treat them the same.
English has the same shape, which makes the trap easy to picture: 'inactive' contains 'active'. A check written as 'status includes active' would treat an inactive record as active. The feed's language has the same structure. The difference is that an engineer who does not read that language has no reason to notice it.
How could a bug like this get past review?
The following is a hypothetical sketch of how this class of bug typically survives. It does not describe how this codebase evolved. In general, substring matching on free-text fields can look like the careful choice, because it tolerates extra whitespace, prefixes and small formatting drift. From there, each safeguard can miss the overlap:
- A reviewer who does not read the language sees a check for 'active' and approves it.
- Test fixtures that only include the active case pass.
- Output looks plausible, because active policies still come out as active.
The defect only appears on the opposite case, and only to someone who reads the original language. That is what makes it a status bug you only hit in someone else's language.
What does Pendora do instead?
The 'is this policy active' check is an exact string match against the value that means active, not a containment test. A status value that merely includes the active word, such as the phrase meaning 'not active', does not satisfy an equality check.
The change is small and not clever. Equality has no hidden overlap with other values. Containment does.
Why write the trap into a code comment instead of just fixing it?
A fix this small is just as easy to undo. Picture a hypothetical future contributor who sees a strict equality check on a text field and changes it to a substring match to make it more forgiving. That would recreate the bug with good intentions. Without the language context, the strict version can look brittle and the loose version can look robust.
The trap is written into the code as a comment so it cannot be re-introduced. The comment carries knowledge about the feed's language that the comparison itself cannot express. It explains why the obvious-looking relaxation is wrong.
How do you audit other localized feeds for the same trap?
Any system that matches status text in a language its engineers do not read can carry this kind of defect. A practical audit:
- List the values the feed actually emits. Enumerate every distinct status value, not just the ones the code expects.
- Test every matcher against every other value. For each value the code looks for, check whether any other emitted value contains it. Any overlap means a contains-style check is unsafe.
- Prefer equality against known values. Match against the enumerated set rather than fragments of text.
- Add negative fixtures. Include the opposite status in tests, not only the happy path. A check that is never shown an inactive record cannot fail on one.
- Have a native reader review the mapping. Someone who reads the feed's language should check how raw status text maps to meaning, because that is where the overlap is visible.
- Document the reason in the code. When a check is stricter than it looks like it needs to be for a language-specific reason, say so in a comment so the next engineer does not loosen it.
The broader point is that logically sound code can still be wrong when it encodes an assumption about vocabulary that does not hold in the data's language. Matching on equality removes that assumption. The comment keeps it from coming back.