You may know the situation. Each team shows that its tool works, the tests pass on both sides, and yet the final result is wrong. That is the signature of an integration bug caused by units. A dimension in centimetres read as millimetres, a weight in grams read as kilos, and a whole render is distorted without a single error message.
I write about it because I have seen it on a project: a mix of centimetres and millimetres between two tools distorted an entire render. Neither tool was at fault. The error lived between them, in an assumption nobody had written down. Here is how I look for this kind of fault, how I fix it in the right place and the test I add so that it does not come back.
01Why a unit bug looks like anything but a bug
An ordinary bug announces itself: a page crashes, a field stays empty, an error message appears. A unit error produces a number. A well-formed number, of the right type, in the right field. The software has no reason to complain, since 150 is a valid number whether it means millimetres or centimetres.
That is why unit tests do not catch it. Each tool is tested with its own data, in its own unit, and it is right. The fault only exists at the moment of the exchange, when one side writes centimetres and the other reads millimetres.
Researchers know the problem well. A study presented at ICSE in 2020 counts around 3,700 software libraries that can handle units. Yet of the 91 practitioners surveyed, few knew about them, and development processes often leave unit information out (McKeever and Salah, ICSE 2020). In other words, most integrations swap bare numbers and rely on a spoken convention.
02What a lost Mars probe teaches ordinary integrations
The most thoroughly documented example comes from space. It still looks a lot like an integration between an ERP and a website. In 1999, NASA lost the Mars Climate Orbiter. The investigation board's report is precise: a file produced by ground software gave pound-force seconds, while the interface specification required newton seconds. Navigation therefore underestimated the effect of the thruster firings by a factor of 4.45, and the computed trajectory was wrong (NASA, Mishap Investigation Board report).
Three details in the report matter more to me than the cause itself:
- the specification existed and stated the right unit; it simply was not followed, and the team reading the file assumed it had been;
- for the first four months, the files had so many format errors that the team worked around them, using notices sent by email; once the files were usable, the anomalous data showed up within a week, but it was already late;
- the end-to-end test of the ground software, which would have compared its output with the specification, does not appear to have been done.
The video Everyday Astronaut made about the accident says something I keep in mind too: it would be easy to blame a single team, but it was a chain of small problems, and finding someone to blame solves nothing (Everyday Astronaut, YouTube). Business integrations are the same. When two suppliers blame each other, I look first for the assumption nobody wrote down.
03Finding the error with a reference object
My way of debugging this kind of integration comes down to one idea: run an object whose values you already know through the whole chain, and watch where they change. It is the logic of the test oracle I built at Moonworkers. It replayed hundreds of contribution cases against HMRC's texts and found errors of a penny, caused by a rounding rule (how I test a calculation with an oracle).
1. Pick a simple reference object
A product, a part or an item with round, easily recognised dimensions: 100 by 200 by 50, for example. Use a different value on each axis, so you can also spot width and height being swapped.
2. Write down its expected values, with the unit, at each step
Before running anything, I note what each tool should hold: 100 mm in the ERP, 10 cm in the catalogue if that is its unit, 0.1 m in a 3D file in glTF format, whose standard sets the metre for all distances (Khronos Group, glTF 2.0 Specification).
3. Follow the value from tool to tool
I look at the raw data at each hop: the export, the file or the API call, then the import. Avoid the final screen, which rounds and formats. The first place where the value no longer matches what I wrote down is where the fault is.
4. Read the gap as a clue
The ratio between the value you got and the value you expected almost always tells you what is going on. A factor of 10 means centimetres and millimetres. A factor of 1,000, grams and kilos, or millimetres and metres. 2.54, inches. 4.45, NASA's pound-force. The W3C gives these equivalences in its table of absolute units: a millimetre is a tenth of a centimetre, an inch is 2.54 centimetres (W3C, CSS Values and Units). A gap that matches none of these ratios often hides something else: rounding, swapped axes, a conversion applied twice.
04Fixing it in the right place: the contract between the tools
Once the error is found, you will be tempted to multiply by ten on import and move on. I avoid that. The fix treats the symptom and leaves the unwritten assumption in place: the day the other tool changes its default unit, everything shifts again, the other way.
I fix the contract instead. In practice:
- in the integration specification, every measurable field has a "unit" column, filled in before all the others, as I describe in how I write an integration specification;
- where possible, the data carries its unit with it rather than relying on a convention; that is what the Schema.org vocabulary does, where a measured value has a unitCode field next to it, holding a standard three-character code (Schema.org, QuantitativeValue);
- a single tool is the reference for each measurement and the others convert from it, which is the thinking behind clean product master data;
- the specification is versioned, so everyone is talking about the same document. On an integration between an ERP and an online shop, it changed at almost every meeting, and the numbered version is what prevented misunderstandings.
Naming the field with its unit, `width_mm` rather than `width`, seems trivial. You still gain a lot for very little effort: whoever writes the import sees the unit without opening the documentation.
05The integration test that stops it coming back
Once the contract is fixed, the reference object becomes a permanent integration test. It runs through the real chain, or through test doubles that have been checked against the real tools. Martin Fowler calls this a contract test: it checks that the doubles return the same thing as the real service, and it has to be rerun when that service changes (Martin Fowler, Contract Test).
Here is the sheet I write for every feed that carries a measurement:
```text Feed : ERP -> website catalogue Object : REF-TEST-001 Input : width 100 mm, height 200 mm, depth 50 mm, weight 1,200 g Expected : width 10 cm, height 20 cm, depth 5 cm, weight 1.2 kg Tolerance : none on dimensions, 0.01 kg on weight When : on every deployment of either tool If gap : block the go-live, alert both teams ```
The "If gap" line matters as much as the others. The NASA report recommended having ground software products signed off by their end users. I do the same on a small scale: the person receiving the data signs the sheet with the person sending it, and the test joins the acceptance testing checklist before go-live.
06What this method does not solve
The reference object catches systematic errors, the ones that shift every value by the same factor. It is weaker on one-off cases: a single product entered in the wrong unit by one person, a value right at a threshold. For those you need several reference objects, plus plausibility checks on the real data (a 2 mm wide wardrobe deserves an alert).
Automated tools do not replace judgement either. A study of robot software examined by hand 180 unit mismatches reported by an analysis tool: some were intended by the developers, and those false positives end up eroding trust in the tool (Canelas et al., ICRA 2024). I would rather have a handful of tests the team understands than a detector that keeps crying wolf.
Finally, the method has a cost: writing down expected values takes time, and someone has to keep the reference objects up to date as the catalogue changes. On an integration with two measurable fields, a well-filled "unit" column is probably enough.
07Where to start on Monday
If you have a wrong result nobody can explain:
- List the measurable fields in the exchange and note, for each one, the unit each tool thinks it uses.
- Pick a reference object with round values that differ on each axis.
- Write down the expected values at each step, then follow the raw data from tool to tool.
- Work out the ratio between the value you got and the value you expected, and look for it among 10, 1,000 and 2.54.
- Fix the specification and the field name, not just the import.
- Keep the reference object as a test, rerun on every deployment.
This is the kind of work I do in technical direction, between the teams that write data and the teams that read it; you will find the detail on the services page and examples in the project portfolio. If you are in the middle of a problem like this, we can talk about it.
