Sometimes you don't need an AI coding agent to fix a bug.
Sometimes you want to see how it thinks.
That was the situation with a manual social sharing bug across two dashboards. The behavior was interesting enough that instead of immediately fixing it, I decided to let an AI coding agent investigate it independently.
I already had a pretty good idea where the problem was.
I wanted to see what the AI would come up with.
The setup
There are two dashboards using the same backend codebase but serving different sites and social integrations.
The first dashboard had:
Facebook connected
Discord connected
LinkedIn connected
The second dashboard had:
Facebook connected
Discord connected
LinkedIn not connected
Publishing an article automatically worked perfectly on both dashboards.
For the second dashboard, publishing and republishing successfully delivered to both Facebook and Discord.
The problem only appeared when using the Manual Share feature.
On the second dashboard:
Manual Facebook share → failed
Manual Discord share → failed
Automatic publishing → worked
The API returned:
CONNECTION_NOT_FOUND
No connected provider to share to — connect the provider first
That was already a pretty useful set of clues.
The integrations were clearly working.
The production connections were clearly working.
The automatic publishing pipeline was clearly working.
And two different providers were failing through the same manual action.
That strongly suggested the problem was somewhere in the shared Manual Share path.
But instead of immediately fixing it, I gave the problem to an AI coding agent.
The first diagnosis
The AI investigated the backend and produced a very confident explanation.
Its theory was that the social connection for the second dashboard had been stored in the wrong Firestore because the Facebook OAuth callback URL pointed at the other backend deployment.
It went deep into:
Firebase projects
siteIdRailway deployments
OAuth redirect URLs
Firestore connection document IDs
Facebook connection storage
It eventually concluded that the second dashboard didn't actually have its Facebook connection where the backend expected it.
The proposed fix was to change the Facebook OAuth redirect configuration and reconnect the Facebook page.
It was a convincing explanation.
It was also wrong.
The problem wasn't that the AI couldn't write the code.
The problem was that it had built an elaborate explanation around an assumption that hadn't been established.
The production behavior didn't agree
There was one inconvenient detail.
Automatic publishing on the second dashboard was already working.
Not just partially working.
The article had been republished and successfully reached both Facebook and Discord.
That meant the production system had valid connections and could successfully resolve and use them.
If the connection really lived in the wrong Firestore project, as the AI suggested, the successful production publishing behavior would have been very difficult to explain.
So the investigation needed to go back to the actual request path.
Instead of asking:
"Why is the Facebook connection missing?"
the better question was:
"Why does Manual Share think it needs a connection that the user never selected?"
That led directly to the relevant code.
The actual problem
The manual share service received a distribution object from the confirmation dialog.
For the second dashboard, the frontend was effectively sending:
{
facebook_page: true,
discord: true
}
LinkedIn wasn't present because it wasn't selected and wasn't available on that dashboard.
The backend, however, was using logic equivalent to:
if (distribution.linkedin !== false) {
// share to LinkedIn
}
At first glance, that looks reasonable.
But JavaScript has an unfortunate little trick here:
undefined !== false
is:
true
So an absent property was being interpreted as an instruction to attempt the share.
The backend was effectively treating:
{
facebook_page: true,
discord: true
}
as though it meant:
{
facebook_page: true,
linkedin: true,
discord: true
}
The Manual Share flow would therefore reach LinkedIn even though the user hadn't selected it.
Since LinkedIn wasn't connected on that dashboard, share() correctly threw CONNECTION_NOT_FOUND.
That exception happened before the remaining distribution targets could complete.
The resulting error made it look like the selected social integrations were broken.
They weren't.
The backend had simply attempted an integration that wasn't part of the request.
The fix
The correct semantics for the Manual Share distribution were actually straightforward:
true → explicitly selected → attempt it
false → explicitly excluded → skip it
undefined → not selected → skip it
So the gates were changed from:
distribution.facebook_page !== false
distribution.linkedin !== false
distribution.discord !== false
to:
distribution.facebook_page === true
distribution.linkedin === true
distribution.discord === true
Now the second dashboard behaves as intended:
Facebook → true → attempt
LinkedIn → undefined → skip
Discord → true → attempt
No connection to LinkedIn is necessary.
And importantly, an explicitly selected provider that isn't connected still produces an error. The fix doesn't hide legitimate failures; it simply stops the backend from inventing selections that the user never made.
We added a regression test
The fix was also accompanied by a focused regression test for the exact scenario.
The test verifies that when:
{
facebook_page: true,
discord: true
}
is provided while LinkedIn is unavailable:
Facebook is attempted
LinkedIn is not attempted
Discord is attempted
CONNECTION_NOT_FOUNDis not thrown
Another test verifies the opposite behavior: if LinkedIn is explicitly set to true while disconnected, the expected connection error is still raised.
That distinction matters.
The goal isn't to make Manual Share silently ignore broken integrations.
The goal is to make it respect the user's actual selection.
What made the experiment interesting
The interesting part wasn't that an AI got a bug wrong.
Humans do that constantly.
What was interesting was how convincing the wrong explanation was.
The AI had enough information to construct a plausible architecture-level theory, and it did exactly that.
It saw:
CONNECTION_NOT_FOUND
and started reasoning about connection storage.
But the more important evidence was behavioral:
Automatic publishing → works
Manual sharing → fails
Two providers → fail through the same feature
One dashboard → works
Another dashboard → fails
Those observations point toward a shared code path much more strongly than they point toward OAuth configuration.
This is one of the things I've found most interesting about using AI for software engineering.
An AI can be extremely good at navigating a large codebase and still arrive at the wrong conclusion if the initial hypothesis isn't constrained by observed behavior.
It can produce a technically sophisticated explanation for the wrong problem.
Why I let it happen
The funny part is that the issue was already understood well enough to investigate manually.
The AI wasn't being used because there was no idea what was happening.
It was being tested.
The goal was essentially:
"Here's the bug. You investigate it independently. Let's see what you find."
That makes the result more useful than simply asking an AI to implement a known fix.
It exposed something worth remembering when working with coding agents:
Having access to the codebase doesn't automatically mean the agent has the right context.
Sometimes the most important debugging information isn't another source file.
It's a sentence like:
"This works in production during automatic publishing. Only the manual action fails."
That single fact can eliminate entire categories of hypotheses.
The better workflow
The experience reinforced a workflow that has been increasingly useful for AI-assisted development:
Establish the actual production behavior.
Reproduce the failure.
Identify what works and what doesn't.
Give the agent those constraints.
Let it trace the relevant code path.
Require evidence before accepting an architectural explanation.
Make the smallest change possible.
Add a regression test for the exact failure.
AI is incredibly useful in that loop.
But the human still needs to control the investigation.
Otherwise, you can end up debugging the AI's theory instead of debugging the software.
And sometimes the difference between those two is one JavaScript boolean comparison.