We send a despatch advice to a supermarket chain for every lorry we load for them. Each one is an EDIFACT DESADV message listing the pallets, the cases on them and where they are going, and the chain's distribution centres will not book in a delivery that arrives without one. On a Friday in October every message we sent them was rejected, thirty eight lorries arrived unannounced, and each was booked in by hand while the drivers waited.

EDIFACT is built from separators. By default a segment ends with an apostrophe, data elements are separated by a plus sign and the components inside them by a colon. A question mark is the release character: written before any of those characters, including itself, it means take the next one literally. A name stored as O'Neill has to go out as O?'Neill.

That week the chain had opened a store at St John's Retail Park, and the address went into the NAD segment for the delivery party exactly as it was typed. Our generator built segments by joining strings with separators, and nothing in it knew about the release character. The apostrophe ended the segment after St John. What followed it, s Retail Park and the rest of the line, was read as the start of a new segment with a tag nobody had heard of.

The chain's translator reported the error in a CONTRL message, the syntax report EDIFACT partners send back, and rejected the whole interchange. We put each day's messages for the chain into one interchange, so a single address took every lorry down with it. The CONTRL arrived within ten minutes. It went into a folder that our integration platform archives without reading, because in four years every CONTRL we had received had said accepted.

The generator now writes every value through an encoder that applies the release character, and its tests include an address with an apostrophe, a plus sign, a colon and a question mark. Every CONTRL that comes back is parsed, and anything other than accepted raises an alert. Each despatch advice now travels in its own interchange, so one bad value can delay only one lorry.

A format built from separators needs an encoder in the same way SQL needs parameters. Our template had worked for four years because nobody had put a separator in a street name.

– Sergey Shinder