Skip to content

Commit e679e8f

Browse files
committed
fix(connectors): isDisconnect only fires on explicit enabled:false
The second branch of the previous `isDisconnect` check evaluated `state.config.connectors[connectorName]?.enabled` AFTER the cloned new config was written into `state.config`, making the check equivalent to "incoming payload omits enabled". Any config-only update (e.g. token rotation) that didn't include the `enabled` field while the connector was previously active would silently fire `onConnectorDisconnect` and purge the live credential cache, breaking the next workflow generation (Greptile P1). Drop the second branch — only treat the POST as a disconnect when the incoming payload explicitly sets `enabled: false`. `wasEnabled` is no longer needed, so it's also removed.
1 parent f43249e commit e679e8f

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

packages/agent/src/api/connector-routes.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,6 @@ export async function handleConnectorRoutes(
148148
return true;
149149
}
150150
if (!state.config.connectors) state.config.connectors = {};
151-
const wasEnabled =
152-
(state.config.connectors[connectorName] as ConnectorConfig | undefined)
153-
?.enabled === true;
154151
state.config.connectors[connectorName] = cloneWithoutBlockedObjectKeys(
155152
config,
156153
) as ConnectorConfig;
@@ -159,11 +156,14 @@ export async function handleConnectorRoutes(
159156
} catch {
160157
/* test envs */
161158
}
162-
const isDisconnect =
163-
(config as ConnectorConfig).enabled === false ||
164-
(wasEnabled &&
165-
(state.config.connectors[connectorName] as ConnectorConfig | undefined)
166-
?.enabled !== true);
159+
// Only treat this POST as a disconnect when the incoming payload
160+
// explicitly sets `enabled: false`. The second clause that read
161+
// `state.config.connectors[connectorName]` would have been evaluated
162+
// AFTER the new (cloned) config was written above, making it equivalent
163+
// to checking the incoming payload — but firing on every config-only
164+
// update that happens to omit `enabled` while the connector was active.
165+
// That false-positive purge silently broke live connectors.
166+
const isDisconnect = (config as ConnectorConfig).enabled === false;
167167
if (isDisconnect && onConnectorDisconnect) {
168168
try {
169169
await onConnectorDisconnect(connectorName);

0 commit comments

Comments
 (0)