My changelog had started duplicating itself, with every release listing its entries twice and the second copy slightly mangled.
The tool generating the changelog reads commit messages and groups them by conventional-commit type. The obvious move is to go and fix the tool: adjust its configuration, filter the duplicates, or if it comes to it, patch its parser.
The duplicates weren't the tool's fault. Merge commits were copying pull request titles into their bodies, so a single change arrived at the parser twice, once as the commit and once inside the merge commit that brought it in. The parser was reading exactly what it had been given, correctly, and there were two of everything to read.
Two places to fix it
Downstream: teach the parser to recognise and skip merge-commit bodies. This works. It's also permanently mine to maintain, it has to survive every upgrade of a tool I don't control, and it leaves the repository still producing malformed input that anything else reading the history will also trip over.
Upstream: stop producing the duplication. Mandate squash merges, so a pull request arrives as one commit with one message and there's nothing to double.
I took the second. The changelog tool went back to stock configuration and the problem stopped existing rather than being handled. Anything else that reads that history in future gets clean input for free, without knowing this ever happened.
Fixing upstream did change a team-facing workflow, which is a bigger ask than a config tweak in a repository nobody else touches. Fixing downstream would have been faster and entirely mine to decide. I wouldn't always choose the same way, and the deciding question is whether the malformed data has other consumers. If it does, the upstream fix pays for itself repeatedly. If the one consumer really is the only one, patching it is proportionate.
The same thing in a workflow trigger
A second case from around the same time makes the pattern clearer, because there the "downstream fix" was the one I had already built.
I had a workflow that auto-merges dependency updates. It was triggered on check suite completion, then filtered inside the job to work out whether the check suite it had just woken up for was one it cared about.
That works, in the sense that the right thing happens. But check suites complete constantly, for every branch and every pull request in the repository, so the workflow was starting up, having a think, and exiting for the overwhelming majority of its runs. The filter was doing its job; the trigger was just firing far too often, and every one of those runs cost something.
The fix was to move the discrimination into the trigger: fire on labelled pull requests only, with a guard on the actor. Roughly half the runs disappeared, and the ones remaining are the ones that had something to do.
It was the same problem as the changelog. In both cases I had a component doing correct work on input it should never have received, and in both cases the durable fix was to stop sending it that input rather than to make it better at rejecting it.
Why the downstream fix is so tempting
It's closer. The symptom appears in the parser, or in the workflow, so that's where you're already looking. The change is smaller, it's in code you own, and you can verify it immediately.
The upstream fix requires you to trace back past the thing that's visibly broken to something that's working as designed, and then change the working thing, which feels wrong. The merge commits weren't defective. Copying pull request titles into merge bodies is normal behaviour. The check suite trigger was firing accurately for events that really occurred.
So in both cases nothing upstream was broken, and upstream was still the right place to fix it. "Where is the defect" and "where is the best fix" are different questions, and I have a habit of answering the first and acting as though I have answered the second.
The question I ask now
When something misbehaves on input it was given, I try to ask who else reads that input. If the answer is "nothing yet", patch the consumer and move on. If the answer is anything else, or plausibly will be, the fix belongs where the input is produced, even when what produces it is behaving perfectly reasonably.
The second question is about volume: is this component doing correct work on input it shouldn't have received, and how often? In the workflow's case, a filter rejecting most of what it saw was a trigger in the wrong place. That one is easy to miss because the filtering is working, and when the result is correct you've no reason to look at what it cost.