I’ve got a patch sitting in a folder on my machine that fixes a bug in someone else’s logging library. It works, I’ve tested it against a real consumer rather than a toy, and the upstream issue asking for exactly that fix has been open since December 2023… and I talked myself out of sending it.
The information that never arrived
The new go/errors puts real structure on an error. Each one carries a kind, and most carry a hint, which is the sentence written for the person who has just hit the problem: not “no config file found” but the sentence telling them to run init first.
Not a bit of it was reaching the terminal. What came out the other end was this:
ERRO failed to load configuration err="no config file found"
The message survived and everything else was thrown away, because charmbracelet/log renders a wrapped error by calling Error() on it and taking the string. Entirely reasonable behaviour for a library that predates most of this, and not a lot of use to me.
Go has a clean answer, and it has had one for years. Implement slog.LogValuer and a value gets the chance to say what it really is before anything renders it. So the fix was obvious, and better still, someone had already asked for it: issue #96, “support log/slog.LogValuer”, opened in December 2023 and still open against v2. An open ticket, an obvious fix, and a library I like. This is the part of open source that’s supposed to be easy…
Doing it the long way round
Before writing a line I went and read the actual documentation to check the support wasn’t there already and that no one had a PR in flight. “This library can’t do X” is the sort of confident claim that falls over the moment someone who knows the codebase reads it (I’ve been that someone, on both ends).
Then the ordinary work: fork it on my own account, write the patch, and test it against a real consumer rather than a toy. And then the boring checks, which are whether there’s a contributor agreement to sign, whether the patch matches the project’s own style rather than mine, and whether any of my local context had leaked into the comments and the diff. A contribution carrying someone else’s variable names and half an argument about a different project isn’t one I’d thank anybody for.
The digging turned up something the ticket didn’t mention. The library isn’t actually without LogValuer support. Its JSON formatter handles one perfectly well: it resolves the value and renders a group as a nested object. The text and logfmt formatters do neither. So the same record carries less information as text than it does as JSON, which is a strange thing for a logger to do:
text err="no config file found"
json {"err":{"msg":"no config file found","kind":"errors.basic","hint":["Run 'init' first"]}}
And that asymmetry looks accidental to me. The commit that added slog attribute support touched the JSON formatter and the two logger files, and left the other two formatters alone, which reads as missed rather than excluded.
There was a second wrinkle underneath it: a value renders differently depending on which door it comes through: the slog.Handler path has already wrapped it by the time a formatter sees it. At this point I had a diagnosis, a patch, and a genuine bug to point at, all lined up.
Reading my own patch as the maintainer
Then I looked at what the fix actually did to the output, which is the step where the whole thing fell apart.
Resolving a LogValuer properly means it renders as dotted keys, which is how slog.TextHandler has always rendered that input:
before user="{id:42 name:matt}"
after user.id=42 user.name=matt
That’s correct. It’s what the standard library produces, it’s what the ticket is asking for, and I’m fairly confident it’s better. It’s also a break, and it lands… on the default formatter!
Whoever has a test asserting on the old rendering sees that test fail the moment they upgrade, not because their code is wrong but because output they had reasonably treated as stable moved under them. The set of values affected is small and defensible (only things implementing LogValuer, which is the very set whose information was being dropped), so you can argue it squarely as a bug fix. I would argue that, and I think I’d be right. But being right isn’t the same as it being my call.
Why it became a report
A visible change to the default output of a widely used library is a compatibility decision, and compatibility decisions belong to the people who have to live with the consequences and answer the issues afterwards. There are several reasonable answers: an option, a v3, or just a line in the release notes. Picking between them is the maintainers’ job, and springing one on them in a pull request they didn’t ask for felt like it wasn’t my place.
So it went upstream as a report rather than a proposal. I commented on the existing issue instead of opening a competing one, laid out what I’d found including the bit about the formatters being missed, said plainly that I had a working patch and had talked myself out of proposing it, and offered to share it if they wanted it. The patch went into a file rather than the bin, on the grounds that they might come back to me one day.
Charm is lovely, the gap is real, and I think the reason it’s still there is that fixing it properly costs someone something. That’s a very different situation to a dependency maintained rationally for someone who isn’t you.
Staying with charm
The other option was to leave. If a library won’t give you what you need, swap it.
So I went and looked at phuslu/log and coder/slog properly, and then stayed with charm, which is roughly what I expected to do. But I wanted staying to be a decision and not inertia, and you only get to call it a decision if you have actually costed the alternative. Throwing away a library I like over one formatter would have been a poor trade.
What went into go-tool-base instead is a wrapper: a handler that resolves the value before charm ever sees it, so the record reaching the formatter is already correct. It sits under a second wrapper that decides what a person should be shown, which is a separate question and stays whatever happens upstream.
The wrapper that expects to be deleted
Have a look at the comment above it, though:
That is a defect being tracked upstream as
charmbracelet/log#96, and the wrapper goes when it lands.
And further down, in the handler that presents the error:
If
charmbracelet/log#96is fixed upstream andNewResolvingHandlergoes away, the group renders as dotted keys instead and the hint stops being buried in a blob.
That’s code written to describe its own obsolescence. It names the issue it is standing in for, states the condition under which it should be removed, and explains what the world looks like on the other side, so whoever finds it in two years knows immediately whether it is still earning its place or is just hanging about because it never got deleted.
So the patch is in a folder, the report is on the ticket, and there’s a comment in my own codebase waiting, very patiently, to be deleted.





