The Two Labels That Sent Work to the Wrong Place

At 4:51 one afternoon, I pushed the last of five changes for a small feature in a tournament administration screen. I had spent the day inside one file that was 47,490 lines long. It was the kind of file where finding a piece of work means jumping to a line number and hoping you landed near the right spot.

The feature sounded ordinary. An administrator needed to choose a child event from a dropdown and work inside it. Think of a school district that has one main office and several schools. The person may sign in through the district office, then open the folder for one school. The screen needed to remember which school they had chosen.

For years, the system carried two labels that always pointed to the same place. One label meant, “the account that signed in.” The other meant, “the account whose work is open right now.” Because they had always matched, the old code treated them as if they were the same thing.

The new dropdown broke that old promise. An administrator could sign in to the parent account, choose a child event, and then work on the child event’s schedule, folders, competitions, or brackets. The second label changed to the child event. The first label stayed with the parent account.

The scary technical term for this is an ambient global. It is just a shared note that many parts of a program can read, and one part can quietly replace. The trouble was not that the file was long. The trouble was that hundreds of lines had learned to trust two labels that no longer always meant the same thing.

Nothing crashed when the labels split apart. That made it worse. A save could succeed, but save information under the parent account instead of the child event the administrator had opened. The work would appear in the wrong place, or seem to disappear because the person was looking in the place they had actually selected.

The first thing I tried was a simple search through the file for every spot that used the sign in account’s name. It gave me a list, but not an answer. A list cannot tell you what happened earlier on a particular trip through the screen. It could not show whether the chosen event had already changed by the time that line ran. I had to trace the path by hand, one save and one screen action at a time.

That was the real cost of the day. The five changes ran from 11:16 to 16:51. More than five and a half hours went into a feature that looked like a dropdown because an old assumption was scattered through so many places.

I found about 80 lines in the main tournament handler that needed the selected event’s name instead of the signed in account’s name. Some were searches. Some were saves. Some were setting parent or group fields. The safer repair was not to flip the old rule for everyone. Most screens still correctly belonged to the account that signed in.

Instead, I made the new choice visible at each affected spot. Where the screen was working inside a selected child event, I explicitly told the helper which account to use. I did that about 27 times across the day’s changes. It was repetitive, and the old function made it clumsy to pass that choice in. Still, each change sat next to the work it affected. There was no hidden switch that could change the meaning of a completely different screen later.

The same care showed up when the screen decided which event to open. With no events, it sends the administrator to create one. With one event, it opens that event. With two or more and no choice yet, it shows a selection view and avoids loading the full set of records. Three plain cases are easier to inspect than one clever rule that tries to guess.

I also removed three old, commented out blocks that had been left nearby. Comments like that can be useful as a note about what someone once tried. They can also turn into a trap, especially when one contains a misspelled name that would do nothing if it were turned back on during a rushed repair.

A 47,490 line file is not automatically a disaster. It can be the record of many small things that needed to keep working. But when one old shortcut says two labels will always match, a new choice can turn that shortcut into work sent to the wrong address.

That day cost roughly five and a half hours and touched about 80 lines, but the fix itself was small: 27 spots where the code now says, in plain sight, which account it means, instead of trusting a label that used to be free.