For most of a day, our own dashboard said our Google Workspace connection was failing. A red bar on every page, a "Failing" badge on the connection, and a reason underneath: the last call had failed.
It had. The call was a search the model had written badly, and Google answered it with a 400 whose message said the query was invalid ("Invalid Input: query"). Nothing was wrong with the credential. Nothing was wrong with Google. The next search, written properly, would have worked, and the hourly sync carried on reading mail and documents through the same connection without a hitch the whole time.
So the indicator was wrong, and wrong in the worst direction. A health light that goes red for a malformed request is a light people learn to ignore, and then it is ignored on the day the token actually dies.
What a health indicator is a claim about
A connection's health answers one question: will the next call through this connection work? That is a claim about the credential and about the system on the other end. It is not a claim about the last request.
Most failed requests say nothing about either. A 404 for a file that was deleted last week, a 400 for a query with a typo in it, a 409 for a record that already exists: each of these is the system working correctly and telling you no. The credential was accepted, the provider answered, and the answer was about the thing you asked for.
A small set of failures does say something about the connection. A 401 means the system rejected the sign-in. A refresh token that the provider refuses means the sign-in cannot be renewed. A rate limit or a 5xx means the next call is likely to fail too, at least for a while. An unreachable host or a TLS failure means the same.
Our classifier already drew this line. failure-kind.ts keeps a list of request statuses (400, 404, 405, 406, 409, 410, 412, 415, 416 and 422) and treats everything else as a connection fault. 401 and 403 are deliberately left off the list: a dead token and a scope nobody granted are exactly what a health page is for, and 403 is ambiguous on several providers, so reading it as a connection fault and sometimes over-reporting is the safer way to be wrong. When there is no status to read at all, the answer is "connection", which is the fail-closed direction. That last rule is what caught us.
How a 400 became a broken connection
Two things went wrong, and neither was the classifier's logic.
The first was that the status code had gone missing before the classifier saw it. Connector code that calls an HTTP API gets back an error object carrying the status. Many connectors then turn that into a sentence a person can act on, something like "Google Workspace refused that (400): invalid: Invalid Input: query". That is a better message for a human, but the wrapper drops the original error, so by the time the outcome was recorded, the number existed only in the prose. statusInMessage knew how to read the two formats our own HTTP helpers write at the start of a message. It did not read a status in parentheses partway through a sentence. No status, so "connection", so red.
The second was that nothing could clear it. Health was computed from three timestamps on the connection row: when it was last used, when it last worked and when it last failed. The rule in connectionHealth is "the last call failed and nothing has succeeded since". But last_ok_at was only ever stamped by tool calls. A sync pass that read fresh mail through the same credential wrote its own sync record and left the connection's timestamps alone. For a connection that exists mostly to be crawled and that nobody calls by hand, there was no next successful call, so the bar stayed up for as long as nobody happened to use a tool through it. The failure was 10:27 one morning. A clean sync ran at 09:04 the next. The connection was still red.
The panel also had little to offer. It said what had failed and when, and left the reader to work out whether that was a problem and what to press.
What we changed
The classifier reads the third shape. statusInMessage now recognises a connector's own sentence with the status in parentheses. It is anchored as tightly as the other two: the message must start with a letter (a vendor's JSON body starts with a brace), the status must be the first parenthesis and within the first 120 characters, and it must end a clause. "Order (123) could not be found" is a sentence about an order, not a status. A message whose first parenthesis is not a status still reads as nothing, which still fails closed. Because health is recomputed from the stored message each time the page is drawn, rows written before the fix were reclassified on the next view.
A crawl that works counts. recordConnectionWorked stamps last_ok_at when a sync pass fetches something, and when a backfill slice completes without error. It deliberately leaves last_used_at alone, so "Last used" still means what a person or the model last did through the connection, not when a background timer ran. A pass that fetched data but skipped one record still counts, because it was still a call through the credential that worked.
The message says what to do. A 401 is now told apart from everything else: the panel says the system rejected the sign-in and offers Reconnect, which signs in again and keeps the connection's permissions and settings. Any other connection fault says to check the credentials and any permission the error names, and that the next call that works clears it. Where the connection is crawled, it adds that a sync run from that same panel counts, so there is always something to press.
Times are exact and in one format. The panel shows "23 Nov 2026, 10:27 (3 h ago)": the moment itself, formatted the same way everywhere, with the relative time beside it. A relative time on its own makes you do arithmetic against a clock you cannot see, and it cannot be compared with a log line.
The assumption is monitored. We keep one monitoring file per assumption, each with the SQL that checks it. The new one says the number of connections judged failing on a call while a clean crawl has run since must be zero. If a later refactor moves the stamp, that count goes up.
The general rules
A health indicator needs a last-success stamp as much as a last-failure one, and every path that proves the connection works has to write it. If only one kind of traffic can clear a failure, a connection that does not see that kind of traffic stays broken on paper for ever.
Classify on structure, not on hope. Keep the status code with the error as long as you can. Where it has to travel as text, parse only the formats your own code writes, anchor them hard, and make "could not tell" land on the side that reports the problem.
Say what happened, when, and what to do. "Failing" on its own is a mood. "The last call failed at 10:27 with a 401; the system rejected the sign-in" is a diagnosis, and the button beside it is the treatment.
Every failing state needs its fix on the same screen. If the right answer is to sign in again, show the Reconnect button. If it is to run a sync, offer the sync.
Do not hide request failures, just do not judge the connection by them. Ours are still written to the failure log and still visible to administrators. A malformed query is worth knowing about. It is not worth a red bar on every page.
Where Memtro stands
Each connection's Health tab now separates a request that was answered no from a connection that will not work, clears itself when a call or a crawl succeeds, and puts the fix beside the reason. The details of what each state means are in the connectors documentation, and the common causes and their remedies are in troubleshooting.